YAML::FlexHash (Class)

In: yaml/rubytypes.rb
Parent: Array

Ruby-specific collection: !ruby/flexhash

Methods

[]   []=   has_key?   is_complex_yaml?   to_yaml  

Public Instance methods

[Source]

# File yaml/rubytypes.rb, line 97
        def []( k )
            self.assoc( k ).to_a[1]
        end

[Source]

# File yaml/rubytypes.rb, line 100
        def []=( k, *rest )
            val, set = rest.reverse
            if ( tmp = self.assoc( k ) ) and not set
                tmp[1] = val
            else
                self << [ k, val ] 
            end
            val
        end

[Source]

# File yaml/rubytypes.rb, line 109
        def has_key?( k )
            self.assoc( k ) ? true : false
        end

[Source]

# File yaml/rubytypes.rb, line 112
        def is_complex_yaml?
            true
        end

[Source]

# File yaml/rubytypes.rb, line 115
        def to_yaml( opts = {} )
            YAML::quick_emit( self.object_id, opts ) { |out|
                out.seq( "!ruby/flexhash" ) { |seq|
                    self.each { |v|
                        if v[1]
                            seq.add( Hash.[]( *v ) )
                        else
                            seq.add( v[0] )
                        end
                    }
                }
            }
        end

[Validate]