A directory service of GPhys.
A GDir object represents a directory, or a file (such as a NetCDF file or GrADS control file), for which GPhys objects can be defined for the variables in it. This means that a NetCDF file, for example, is treated a directory, rather than a plain file.
Suitable for remote service using dRuby.
GDir.top=(top)
Sets the root directory. This should be done before making any GDir objects by GDir.new. The default root directory is the root directory of the local file system ('/').
ARGUMENTS
RETURN VALUE
GDir.top
RETURN VALUE
GDir.new(path)
Constructor.
ARGUMENTS
RETURN VALUE
ERRORS
EXAMPLES
If the top directory is "/hoge", you can open "/hoge/ho" directory by any of the following.
gdir = GDir.new("/ho") gdir = GDir.new("./ho")
If you want to open "/hoge" (the top directly), then
gdir = GDir.new("/") gdir = GDir.new(".")
To open a NetCDF file or GrADS control file,
gdir = GDir.new("/ho/data.nc") gdir = GDir.new("/ho/data.ctl")
GDir.set_text_pattern(*regexps)
Sets regular expressions to match the file name of text files. The default is /\.txt$/ and /^\w*$/.
ARGUMENTS
RETURN VALUE
ERRORS
GFile.add_text_pattern(regexp [, regexp [, ...]])
Similar to GFile.set_text_pattern, but adds regular expressions instead of replacing existing ones.
RETURN VALUE
ERRORS
path
Returns the path (relative to the top directory)
RETURN VALUE
name
Name of the GDir
inspect
Returns the path
list_dir(path=nil)
Returns the names of the directories.
ARGUMENTS
RETURN VALUE
list_data(path=nil)
Returns the names of the data (variables on which GPhys objects can be defined.) Returns a non-empty array if the GDir (current or at the path) is actually a file recognized by GPhys (i.e., NetCDF or GrADS control file).
ARGUMENTS
RETURN VALUE
list_texts(path=nil)
Returns the names of the text files. Whether a file is a text file or not is judged based on the name of the file: That matched the predefined patters is judged as a text file regardless whether it is really so. The default pattern is /\.txt$/ and /^\w*$/. The patterns can be customized by set_text_patterns or add_text_patterns.
ARGUMENTS
RETURN VALUE
dir(path)
Returns a GDir specified the path.
ARGUMENTS
RETURN VALUE
ERROR
data(path)
Returns a GPhys specified the path.
ARGUMENTS
RETURN VALUE
ERROR
text(path)
Returns a text file object specified the path.
ARGUMENTS
RETURN VALUE
ERROR
[path]
Returns a GDir, GPhys, or File (text), by using dir, data, or text.
ARGUMENTS
RETURN VALUE
ERROR