| Class | YAML::YamlNode |
| In: |
lib/yaml/yamlnode.rb
|
| Parent: | Object |
| anchor | [RW] | |
| kind | [RW] | |
| type_id | [RW] | |
| value | [RW] |
# File lib/yaml/yamlnode.rb, line 14
14: def initialize( t, v )
15: @type_id = t
16: if Hash === v
17: @kind = 'map'
18: @value = {}
19: v.each { |k,v|
20: @value[ k.transform ] = [ k, v ]
21: }
22: elsif Array === v
23: @kind = 'seq'
24: @value = v
25: elsif String === v
26: @kind = 'scalar'
27: @value = v
28: end
29: end
Transform this node fully into a native type
# File lib/yaml/yamlnode.rb, line 34
34: def transform
35: t = nil
36: if @value.is_a? Hash
37: t = {}
38: @value.each { |k,v|
39: t[ k ] = v[1].transform
40: }
41: elsif @value.is_a? Array
42: t = []
43: @value.each { |v|
44: t.push v.transform
45: }
46: else
47: t = @value
48: end
49: YAML.transfer_method( @type_id, t )
50: end