Ruby API Document

Google

content="text/html; charset=iso-2022-jp"> previous - up - next - index

Properties

Super Class:

Object

Included Module:

Enumerable

Class Description:

The Properties class provides simple properties database able to be {stored into/restored from} human-readable format file. Property is a mapping from key to value used as resources by applications.

For objects val used as property values, eval(val.inspect) == val must hold so that you can restore properties after storing. If not so, you must implement an appropriate inspect method for value class.

Example:

default = Properties.new
default.load('test.default')
prop = Properties.new(default)
prop.load('dot.testrc')
print("dict_file = "); p(prop['dict_file'])

Class Methods:

  • new([default])
    Returns a newly created properties set with default properties default .

Instance Methods:

  • self[key[, default]]
  • getProperty(key[, default])
    Returns the value of the property specified by key . When there is not the property, returns the default value default if it is specified, returns nil otherwise.
  • self[key]=val
  • setProperty(key, val)
    Sets a value val to the property which has the specified name key . Returns the previous value, or nil when the property has no value.
  • load(file)
    Reads properties from a file if file is String , from a stream if file is IO .
  • save(file)
    Writes properties to a file if file is String , to a stream if file is IO .
  • default
  • default=default_prop
    Properties object for dafault values.
  • list(port)
  • dump(port)
    Writes properties list to port stream. (for debug)

previous - up - next - index

Author: igarashi@ueda.info.waseda.ac.jp

Generated at Mon Mar 08 17:05:27 JST 1999 by rubyapi2