Class

YAML + DBM = YDBM

YAML::DBM provides the same interface as ::DBM.

However, while DBM only allows strings for both keys and values, this library allows one to use most Ruby objects for values by first converting them to YAML. Keys must be strings.

Conversion to and from YAML is performed automatically.

See the documentation for ::DBM and ::YAML for more information.

Constants
No documentation available
Instance Methods

Return value associated with key from database.

Returns nil if there is no such key.

See fetch for more information.

Set key to value in database.

value will be converted to YAML before storage.

See store for more information.

Deletes value from database associated with key.

Returns value or nil.

Calls the given block once for each key, value pair in the database. Deletes all entries for which the block returns true.

Returns self.

An alias for each_pair

Calls the given block once for each key, value pair in the database.

Returns self.

Calls the given block for each value in database.

Returns self.

Return value associated with key.

If there is no value for key and no block is given, returns ifnone.

Otherwise, calls block passing in the given key.

See ::DBM#fetch for more information.

Returns true if specified value is found in the database.

Deprecated, used YAML::DBM#key instead.


Note: YAML::DBM#index makes warning from internal of ::DBM#index. It says ‘DBM#index is deprecated; use DBM#key’, but DBM#key behaves not same as DBM#index.

Returns a Hash (not a DBM database) created by using each value in the database as a key, with the corresponding key as its value.

Note that all values in the hash will be Strings, but the keys will be actual objects.

Returns the key for the specified value.

Converts the contents of the database to an in-memory Hash, then calls Hash#reject with the specified code block, returning a new Hash.

Replaces the contents of the database with the contents of the specified object. Takes any object which implements the each_pair method, including Hash and DBM objects.

If a block is provided, returns a new array containing [key, value] pairs for which the block returns true.

Otherwise, same as values_at

Removes a [key, value] pair from the database, and returns it. If the database is empty, returns nil.

The order in which values are removed/returned is not guaranteed.

Stores value in database with key as the index. value is converted to YAML before being stored.

Returns value

Converts the contents of the database to an array of [key, value] arrays, and returns it.

Converts the contents of the database to an in-memory Hash object, and returns it.

Updates the database with multiple values from the specified object. Takes any object which implements the each_pair method, including Hash and DBM objects.

Returns self.

Returns an array of values from the database.

Returns an array containing the values associated with the given keys.