class NumRu::GDir

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.

Class Methods

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

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

Instance Methods

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