DBM

DBM is the class to provide access to the DBM files. It acts string to string dictionary, storing data in the DBM file.

SuperClass:

Object

Included Modules:

Enumerable

Class Method:

open(dbname[, mode])

Opens the DBM database specified by dbname, with mode. The default value for the mode is 0666. If nil is specified for the mode, open returns nil, if the DBM file does not exist.

Method:

self[key]

Returns the value corresponding the key.

self[key] = value

Stores the value associating with key. If nil is given as the value, the association from the key will be removed.

clear

Makes the DBM file empty.

close

Closes the DBM file. Later operation raises an exception.

delete(key)

Removes the association from the key.

delete_if { |key, value| ... }

Deletes associations if the evaluation of the block returns true.

each {|key, value| ... }
each {|key, value| ... }

Iterates over associations.

each_key {|key| ... }

Iterates over keys.

each_value {|value| ... }

Iterates over values.

empty?()

Returns true if the database is empty.

has_key?(key)
key?(key)
include?(key)

Returns true if the association from the key exists.

has_value?(value)
value?(value)

Returns true if the association to the value exists.

indexes(key_1,...)
indices(key_1,...)

Returns an array contains items at each key specified by each argument.

keys

Returns the array of the keys in the DBM dictionary.

length
size

Returns the number of association in the DBM dictionary. Current implementation uses iteration over all associations to count, so that it may take time to get the size of the huge DBM dictionary.

shift

Removes and returns an association from the database.

values

Returns the array of the values in the DBM dictionary.