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.
- #
- D
- E
- F
- H
- I
- K
- R
- S
- T
- U
- V
Instance Public methods
ydbm[key] → value Link
Return value associated with key from database.
Returns nil if there is no such key.
See fetch for more information.
ydbm[key] = value Link
ydbm.delete(key) Link
Deletes value from database associated with key.
Returns value or nil.
ydbm.delete_if { |key, value| ... } Link
Calls the given block once for each key, value pair in the database. Deletes all entries for which the block returns true.
Returns self.
each_pair() Link
Calls the given block once for each key, value pair in the database.
Returns self.
ydbm.each_value { |value| ... } Link
Calls the given block for each value in database.
Returns self.
ydbm.fetch( key, ifnone = nil )
ydbm.fetch( key ) { |key| ... }
Link
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.
ydbm.has_value?(value) Link
Returns true if specified value is found in the database.
index( keystr ) Link
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.
ydbm.invert → hash Link
ydbm.key(value) → string Link
Returns the key for the specified value.
ydbm.reject { |key, value| ... } Link
Converts the contents of the database to an in-memory Hash, then calls Hash#reject with the specified code block, returning a new Hash.
ydbm.replace(hash) → ydbm Link
ydbm.select { |key, value| ... }
ydbm.select(*keys)
Link
If a block is provided, returns a new array containing [key, value] pairs for which the block returns true.
Otherwise, same as values_at
ydbm.shift → [key, value] Link
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.
ydbm.store(key, value) → value Link
Stores value in database with key as the index. value is converted to YAML before being stored.
Returns value
ydbm.to_a → array Link
Converts the contents of the database to an array of [key, value] arrays, and returns it.
ydbm.to_hash → hash Link
Converts the contents of the database to an in-memory Hash object, and returns it.
ydbm.update(hash) → ydbm Link
ydbm.values Link
Returns an array of values from the database.