Class: Syck::YamlNode
Overview
YAML Generic Model container
Instance Attribute Summary collapse
-
#anchor ⇒ Object
Returns the value of attribute anchor.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#type_id ⇒ Object
Returns the value of attribute type_id.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(t, v) ⇒ YamlNode
constructor
A new instance of YamlNode.
-
#transform ⇒ Object
Transform this node fully into a native type.
Methods included from BaseNode
#[], #at, #children, #children_with_index, #emit, #match_path, #match_segment, #search, #select, #select!
Constructor Details
#initialize(t, v) ⇒ YamlNode
Returns a new instance of YamlNode.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/syck/yamlnode.rb', line 14 def initialize(t, v) @type_id = t if Hash === v @kind = 'map' @value = {} v.each {|key,val| @value[key.transform] = [key, val] } elsif Array === v @kind = 'seq' @value = v elsif String === v @kind = 'scalar' @value = v end end |
Instance Attribute Details
#anchor ⇒ Object
Returns the value of attribute anchor
13 14 15 |
# File 'lib/syck/yamlnode.rb', line 13 def anchor @anchor end |
#kind ⇒ Object
Returns the value of attribute kind
13 14 15 |
# File 'lib/syck/yamlnode.rb', line 13 def kind @kind end |
#type_id ⇒ Object
Returns the value of attribute type_id
13 14 15 |
# File 'lib/syck/yamlnode.rb', line 13 def type_id @type_id end |
#value ⇒ Object
Returns the value of attribute value
13 14 15 |
# File 'lib/syck/yamlnode.rb', line 13 def value @value end |
Instance Method Details
#transform ⇒ Object
Transform this node fully into a native type
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/syck/yamlnode.rb', line 34 def transform t = nil if @value.is_a? Hash t = {} @value.each { |k,v| t[ k ] = v[1].transform } elsif @value.is_a? Array t = [] @value.each { |v| t.push v.transform } else t = @value end Syck.transfer_method( @type_id, t ) end |