Class: Hash

Inherits:
Object show all
Defined in:
lib/syck/rubytypes.rb

Direct Known Subclasses

Syck::Set, Syck::SpecialHash

Instance Method Summary collapse

Instance Method Details

#to_yaml(opts = {}) ⇒ Object


39
40
41
42
43
44
45
46
47
48
# File 'lib/syck/rubytypes.rb', line 39

def to_yaml( opts = {} )
       return super unless YAML::ENGINE.syck?
	YAML::quick_emit( self, opts ) do |out|
           out.map( taguri, to_yaml_style ) do |map|
               each do |k, v|
                   map.add( k, v )
               end
           end
       end
end

#yaml_initialize(tag, val) ⇒ Object


30
31
32
33
34
35
36
37
38
# File 'lib/syck/rubytypes.rb', line 30

def yaml_initialize( tag, val )
    if Array === val
        update Hash.[]( *val )		# Convert the map to a sequence
    elsif Hash === val
        update val
    else
        raise YAML::TypeError, "Invalid map explicitly tagged #{ tag }: " + val.inspect
    end
end