class Psych::Nodes::Node - Documentation for Ruby 4.0
Description: class Psych::Nodes::Node: The base class for any Node in a YAML parse tree. This class should never be instantiated.
Keywords: ruby,class,Psych::Nodes::Node

🔍

No recent searches

# 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

end_column [RW]

The column number where this node ends

end_line [RW]

The line number where this node ends

start_column [RW]

The column number where this node start

start_line [RW]

The line number where this node start

tag [R]

An associated tag

### Public Class Methods

new ()
Source

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

Create a new `Psych::Nodes::Node`

### Public Instance Methods

alias? ()
Source

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

document? ()
Source

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

each (&block)
Source

    # File ext/psych/lib/psych/nodes/node.rb, line 39
    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.

mapping? ()
Source

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

scalar? ()
Source

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

sequence? ()
Source

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

stream? ()
Source

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

to_ruby (symbolize_names: false, freeze: false, strict_integer: false, parse_symbols: true)
Source

    # File ext/psych/lib/psych/nodes/node.rb, line 48
    def to_ruby(symbolize_names: false, freeze: false, strict_integer: false, parse_symbols: true)
      Visitors::ToRuby.create(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer, parse_symbols: parse_symbols).accept(self)
    end

Convert this node to Ruby.

See also `Psych::Visitors::ToRuby`

Also aliased as: transform
to_yaml (io = nil, options = {})
Alias for: yaml
transform (symbolize_names: false, freeze: false, strict_integer: false, parse_symbols: true)
Alias for: to_ruby
yaml (io = nil, options = {})
Source

    # File ext/psych/lib/psych/nodes/node.rb, line 57
    def yaml io = nil, options = {}
      require "stringio" unless defined?(StringIO)

      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`

Also aliased as: to_yaml