Class: Psych::Nodes::Node
Overview
The base class for any Node in a YAML parse tree. This class should never be instantiated.
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
The children of this node.
-
#tag ⇒ Object
readonly
An associated tag.
Instance Method Summary collapse
-
#initialize ⇒ Node
constructor
Create a new Psych::Nodes::Node.
-
#to_ruby ⇒ Object
(also: #transform)
Convert this node to Ruby.
-
#to_yaml(io = nil) ⇒ Object
Convert this node to YAML.
Constructor Details
#initialize ⇒ Node
Create a new Psych::Nodes::Node
16 17 18 |
# File 'lib/psych/nodes/node.rb', line 16 def initialize @children = [] end |
Instance Attribute Details
#children ⇒ Object (readonly)
The children of this node
10 11 12 |
# File 'lib/psych/nodes/node.rb', line 10 def children @children end |
#tag ⇒ Object (readonly)
An associated tag
13 14 15 |
# File 'lib/psych/nodes/node.rb', line 13 def tag @tag end |
Instance Method Details
#to_ruby ⇒ Object Also known as: transform
Convert this node to Ruby.
See also Psych::Visitors::ToRuby
24 25 26 |
# File 'lib/psych/nodes/node.rb', line 24 def to_ruby Visitors::ToRuby.new.accept self end |
#to_yaml(io = nil) ⇒ Object
Convert this node to YAML.
See also Psych::Visitors::Emitter
33 34 35 36 37 38 39 |
# File 'lib/psych/nodes/node.rb', line 33 def to_yaml io = nil real_io = io || StringIO.new Visitors::Emitter.new(real_io).accept self return real_io.string unless io io end |