DBM
# File yaml/dbm.rb, line 14 def []=( key, val ) store( key, val ) end
# File yaml/dbm.rb, line 35 def delete( key ) v = super( key ) if String === v v = YAML::load( v ) end v end
# File yaml/dbm.rb, line 42 def delete_if del_keys = keys.dup del_keys.delete_if { |k| yield( k, fetch( k ) ) == false } del_keys.each { |k| delete( k ) } self end
# File yaml/dbm.rb, line 52 def each_pair keys.each { |k| yield k, fetch( k ) } self end
# File yaml/dbm.rb, line 56 def each_value super { |v| yield YAML::load( v ) } self end
# File yaml/dbm.rb, line 17 def fetch( keystr, ifnone = nil ) begin val = super( keystr ) return YAML::load( val ) if String === val rescue IndexError end if block_given? yield keystr else ifnone end end
# File yaml/dbm.rb, line 63 def has_value?( val ) each_value { |v| return true if v == val } return false end
# File yaml/dbm.rb, line 29 def index( keystr ) super( keystr.to_yaml ) end
# File yaml/dbm.rb, line 67 def invert h = {} keys.each { |k| h[ self.fetch( k ) ] = k } h end
# File yaml/dbm.rb, line 48 def reject hsh = self.to_hash hsh.reject { |k,v| yield k, v } end
# File yaml/dbm.rb, line 72 def replace( hsh ) clear update( hsh ) end
# File yaml/dbm.rb, line 81 def select( *keys ) if block_given? self.keys.collect { |k| v = self[k]; [k, v] if yield k, v }.compact else values_at( *keys ) end end
# File yaml/dbm.rb, line 76 def shift a = super a[1] = YAML::load( a[1] ) if a a end
# File yaml/dbm.rb, line 88 def store( key, val ) super( key, val.to_yaml ) val end
# File yaml/dbm.rb, line 98 def to_a a = [] keys.each { |k| a.push [ k, self.fetch( k ) ] } a end
# File yaml/dbm.rb, line 103 def to_hash h = {} keys.each { |k| h[ k ] = self.fetch( k ) } h end
# File yaml/dbm.rb, line 92 def update( hsh ) hsh.keys.each do |k| self.store( k, hsh.fetch( k ) ) end self end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.