Class: Psych::Nodes::Node

Inherits:
Object show all
Defined in:
lib/psych/nodes/node.rb

Overview

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

Direct Known Subclasses

Alias, Document, Mapping, Scalar, Sequence, Stream

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

Create a new Psych::Nodes::Node



16
17
18
# File 'lib/psych/nodes/node.rb', line 16

def initialize
  @children = []
end

Instance Attribute Details

#childrenObject (readonly)

The children of this node



10
11
12
# File 'lib/psych/nodes/node.rb', line 10

def children
  @children
end

#tagObject (readonly)

An associated tag



13
14
15
# File 'lib/psych/nodes/node.rb', line 13

def tag
  @tag
end

Instance Method Details

#to_rubyObject 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