Skip to Content Skip to Search

The base class for any Node in a YAML parse tree. This class should never be instantiated.

Methods
A
D
E
M
N
S
T
Y
Included Modules

Attributes

[R] children

The children of this node

[RW] end_column

The column number where this node ends

[RW] end_line

The line number where this node ends

[RW] start_column

The column number where this node start

[RW] start_line

The line number where this node start

[R] tag

An associated tag

Class Public methods

new()

Create a new Psych::Nodes::Node

# File ruby/ext/psych/lib/psych/nodes/node.rb, line 33
def initialize
  @children = []
end

Instance Public methods

alias?()

# File ruby/ext/psych/lib/psych/nodes/node.rb, line 67
def alias?;    false; end

document?()

# File ruby/ext/psych/lib/psych/nodes/node.rb, line 68
def document?; false; end

each(&block)

Iterate over each node in the tree. Yields each node to block depth first.

# File ruby/ext/psych/lib/psych/nodes/node.rb, line 40
def each &block
  return enum_for :each unless block_given?
  Visitors::DepthFirst.new(block).accept self
end

mapping?()

# File ruby/ext/psych/lib/psych/nodes/node.rb, line 69
def mapping?;  false; end

scalar?()

# File ruby/ext/psych/lib/psych/nodes/node.rb, line 70
def scalar?;   false; end

sequence?()

# File ruby/ext/psych/lib/psych/nodes/node.rb, line 71
def sequence?; false; end

stream?()

# File ruby/ext/psych/lib/psych/nodes/node.rb, line 72
def stream?;   false; end

to_ruby(symbolize_names: false, freeze: false, strict_integer: false)

Convert this node to Ruby.

See also Psych::Visitors::ToRuby

Also aliased as: transform
# File ruby/ext/psych/lib/psych/nodes/node.rb, line 49
def to_ruby(symbolize_names: false, freeze: false, strict_integer: false)
  Visitors::ToRuby.create(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer).accept(self)
end

to_yaml(io = nil, options = {})

Alias for: yaml

transform(symbolize_names: false, freeze: false, strict_integer: false)

Alias for: to_ruby

yaml(io = nil, options = {})

Convert this node to YAML.

See also Psych::Visitors::Emitter

Also aliased as: to_yaml
# File ruby/ext/psych/lib/psych/nodes/node.rb, line 58
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