|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jruby.RubyObject
org.jruby.RubyDir
.The Ruby built-in class Dir.
Field Summary | |
protected java.io.File |
dir
|
protected java.lang.String |
path
|
Fields inherited from class org.jruby.RubyObject |
runtime |
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject |
NULL_ARRAY |
Constructor Summary | |
RubyDir(Ruby ruby,
RubyClass type)
|
Method Summary | |
static IRubyObject |
chdir(IRubyObject recv,
RubyString path)
Changes the current directory to path |
static IRubyObject |
chroot(IRubyObject recv,
RubyString path)
Changes the root directory (only allowed by super user). |
IRubyObject |
close()
Closes the directory stream. |
static RubyClass |
createDirClass(Ruby ruby)
|
IRubyObject |
each()
Executes the block once for each entry in the directory. |
static RubyArray |
entries(IRubyObject recv,
RubyString path)
Returns an array containing all of the filenames in the given directory. |
static IRubyObject |
foreach(IRubyObject recv,
RubyString path)
Executes the block once for each file in the directory specified by path . |
protected static java.util.List |
getContents(java.io.File directory)
Returns the contents of the specified directory as an
ArrayList containing the names of the files as Java Strings. |
protected static java.util.List |
getContents(java.io.File directory,
Ruby ruby)
Returns the contents of the specified directory as an
ArrayList containing the names of the files as Ruby Strings. |
protected static java.io.File |
getDir(Ruby ruby,
java.lang.String path)
Returns a Java File object for the specified path. |
static RubyString |
getwd(IRubyObject recv)
Returns the current directory. |
static RubyArray |
glob(IRubyObject recv,
RubyString pat)
Returns an array of filenames matching the specified wildcard pattern pat . |
IRubyObject |
initialize(RubyString path)
Creates a new Dir . |
boolean |
matches(java.lang.String str,
java.lang.String pattern)
|
static IRubyObject |
mkdir(IRubyObject recv,
IRubyObject[] args)
Creates the directory specified by path . |
static IRubyObject |
newInstance(IRubyObject recv,
IRubyObject[] args)
|
static IRubyObject |
open(IRubyObject recv,
RubyString path)
Returns a new directory object for path . |
RubyString |
read()
Returns the next entry from this directory. |
IRubyObject |
rewind()
Moves position in this directory to the first entry. |
static IRubyObject |
rmdir(IRubyObject recv,
RubyString path)
Deletes the directory specified by path . |
IRubyObject |
seek(RubyFixnum pos)
Moves to a position d . |
RubyInteger |
tell()
Returns the current position in the directory. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.String path
protected java.io.File dir
Constructor Detail |
public RubyDir(Ruby ruby, RubyClass type)
Method Detail |
public static RubyClass createDirClass(Ruby ruby)
public static IRubyObject newInstance(IRubyObject recv, IRubyObject[] args)
public IRubyObject initialize(RubyString path)
Dir
. This method takes a snapshot of the
contents of the directory at creation time, so changes to the contents
of the directory will not be reflected during the lifetime of the
Dir
object returned, so a new Dir
instance
must be created to reflect changes to the underlying file system.
public static RubyArray glob(IRubyObject recv, RubyString pat)
pat
.
public static RubyArray entries(IRubyObject recv, RubyString path)
public static IRubyObject chdir(IRubyObject recv, RubyString path)
path
public static IRubyObject chroot(IRubyObject recv, RubyString path)
public static IRubyObject rmdir(IRubyObject recv, RubyString path)
path
. The directory must
be empty.
public static IRubyObject foreach(IRubyObject recv, RubyString path)
path
.
public static RubyString getwd(IRubyObject recv)
public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args)
path
. Note that the
mode
parameter is provided only to support existing Ruby
code, and is ignored.
public static IRubyObject open(IRubyObject recv, RubyString path)
path
. If a block is
provided, a new directory object is passed to the block, which closes the
directory object before terminating.
public IRubyObject close()
public IRubyObject each()
public RubyInteger tell()
public IRubyObject seek(RubyFixnum pos)
d
. pos
must be a value
returned by tell
or 0.
public RubyString read()
public IRubyObject rewind()
protected static java.io.File getDir(Ruby ruby, java.lang.String path)
File
object for the specified path. If
path
is not a directory, throws IOError
.
path
- path for which to return the File
object.
IOError
- if path
is not a directory.protected static java.util.List getContents(java.io.File directory)
directory
as an
ArrayList
containing the names of the files as Java Strings.
protected static java.util.List getContents(java.io.File directory, Ruby ruby)
directory
as an
ArrayList
containing the names of the files as Ruby Strings.
public boolean matches(java.lang.String str, java.lang.String pattern)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |