Class | YAML::DBM
In: | yaml/dbm.rb
Parent: | ::DBM

### Methods

[] []= delete delete_if each each_pair each_value fetch has_value? index invert reject replace select shift store to_a to_hash update values values_at

### Constants

VERSION | = | "0.1"

### Public Instance methods

[]( key )

[Source]

    # File yaml/dbm.rb, line 11
        def []( key )
            fetch( key )
        end

[]=( key, val )

[Source]

    # File yaml/dbm.rb, line 14
        def []=( key, val )
            store( key, val )
        end

delete( key )

[Source]

    # File yaml/dbm.rb, line 35
        def delete( key )
            v = super( key )
            if String === v
                v = YAML::load( v )
            end
            v
        end

delete_if() {|k, fetch( k )| ...}

[Source]

    # 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

each()

Alias for each_pair

each_pair() {|k, fetch( k ) }| ...}

[Source]

    # File yaml/dbm.rb, line 52
        def each_pair
            keys.each { |k| yield k, fetch( k ) }
            self
        end

each_value() {|YAML::load( v ) }| ...}

[Source]

    # File yaml/dbm.rb, line 56
        def each_value
            super { |v| yield YAML::load( v ) }
            self
        end

fetch( keystr, ifnone = nil ) {|keystr| ...}

[Source]

    # 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

has_value?( val )

[Source]

    # File yaml/dbm.rb, line 63
        def has_value?( val )
            each_value { |v| return true if v == val }
            return false
        end

index( keystr )

[Source]

    # File yaml/dbm.rb, line 29
        def index( keystr )
            super( keystr.to_yaml )
        end

invert()

[Source]

    # File yaml/dbm.rb, line 67
        def invert
            h = {}
            keys.each { |k| h[ self.fetch( k ) ] = k }
            h
        end

reject() {|k, v| ...}

[Source]

    # File yaml/dbm.rb, line 48
        def reject
            hsh = self.to_hash
            hsh.reject { |k,v| yield k, v }
        end

replace( hsh )

[Source]

    # File yaml/dbm.rb, line 72
        def replace( hsh )
            clear
            update( hsh )
        end

select( *keys ) {|k, v| ...}

[Source]

    # 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

shift()

[Source]

    # File yaml/dbm.rb, line 76
        def shift
            a = super
            a[1] = YAML::load( a[1] ) if a
            a
        end

store( key, val )

[Source]

    # File yaml/dbm.rb, line 88
        def store( key, val )
            super( key, val.to_yaml )
            val
        end

to_a()

[Source]

    # File yaml/dbm.rb, line 98
        def to_a
            a = []
            keys.each { |k| a.push [ k, self.fetch( k ) ] }
            a
        end

to_hash()

[Source]

    # File yaml/dbm.rb, line 103
        def to_hash
            h = {}
            keys.each { |k| h[ k ] = self.fetch( k ) }
            h
        end

update( hsh )

[Source]

    # File yaml/dbm.rb, line 92
        def update( hsh )
            hsh.keys.each do |k|
                self.store( k, hsh.fetch( k ) )
            end
            self
        end

values()

[Source]

    # File yaml/dbm.rb, line 60
        def values
            super.collect { |v| YAML::load( v ) }
        end

values_at( *keys )

[Source]

    # File yaml/dbm.rb, line 32
        def values_at( *keys )
            keys.collect { |k| fetch( k ) }
        end

[Validate]