class Psych::Nodes::Node
The base class for any Node in a YAML parse tree. This class should never be instantiated.
Attributes
children[R]
The children of this node
tag[R]
An associated tag
Public Class Methods
new()
click to toggle source
Create a new Psych::Nodes::Node
# File ext/psych/lib/psych/nodes/node.rb, line 18 def initialize @children = [] end
Public Instance Methods
each(&block)
click to toggle source
Iterate over each node in the tree. Yields each node to block
depth first.
# File ext/psych/lib/psych/nodes/node.rb, line 25 def each &block return enum_for :each unless block_given? Visitors::DepthFirst.new(block).accept self end
to_ruby()
click to toggle source
Convert this node to Ruby.
See also Psych::Visitors::ToRuby
# File ext/psych/lib/psych/nodes/node.rb, line 34 def to_ruby Visitors::ToRuby.new.accept self end
Also aliased as: transform
yaml(io = nil, options = {})
click to toggle source
Convert this node to YAML.
See also Psych::Visitors::Emitter
# File ext/psych/lib/psych/nodes/node.rb, line 43 def yaml io = nil, options = {} real_io = io || StringIO.new(''.encode('utf-8')) Visitors::Emitter.new(real_io, options).accept self return real_io.string unless io io end
Also aliased as: to_yaml