Class
The base class for any Node
in a YAML parse tree. This class should never be instantiated.
Attributes
Read
The children of this node
Read
An associated tag
Class Methods
::
ext/psych/lib/psych/nodes/node.rb
View on GitHub
# File tmp/rubies/ruby-2.4.10/ext/psych/lib/psych/nodes/node.rb, line 21
def initialize
@children = []
end
Create a new Psych::Nodes::Node
Instance Methods
ext/psych/lib/psych/nodes/node.rb
View on GitHub
# File tmp/rubies/ruby-2.4.10/ext/psych/lib/psych/nodes/node.rb, line 28
def each &block
return enum_for :each unless block_given?
Visitors::DepthFirst.new(block).accept self
end
Iterate over each node in the tree. Yields each node to block
depth first.
#
ext/psych/lib/psych/nodes/node.rb
View on GitHub
# File tmp/rubies/ruby-2.4.10/ext/psych/lib/psych/nodes/node.rb, line 37
def to_ruby
Visitors::ToRuby.create.accept(self)
end
Convert this node to Ruby.
See also Psych::Visitors::ToRuby
ext/psych/lib/psych/nodes/node.rb
View on GitHub
An alias for yaml
ext/psych/lib/psych/nodes/node.rb
View on GitHub
# File tmp/rubies/ruby-2.4.10/ext/psych/lib/psych/nodes/node.rb, line 46
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
Convert this node to YAML.
See also Psych::Visitors::Emitter