Class: Psych::Nodes::Node (Ruby 2.7.5)
Description: Class : Psych::Nodes::Node - Ruby 2.7.5

### Home Classes Methods

### In Files

- psych/lib/psych/nodes/node.rb

### Parent

Object

### Methods

- ::new
- #alias?
- #document?
- #each
- #mapping?
- #scalar?
- #sequence?
- #stream?
- #to_ruby
- #to_yaml
- #transform
- #yaml

### Included Modules

- Enumerable

### Class/Module Index

Quicksearch

- Kernel
- Object
- Psych
- Psych::BadAlias
- Psych::ClassLoader
- Psych::ClassLoader::Restricted
- Psych::Coder
- Psych::DisallowedClass
- Psych::Emitter
- Psych::Exception
- Psych::Handler
- Psych::Handler::DumperOptions
- Psych::Handlers
- Psych::Handlers::Recorder
- Psych::JSON
- Psych::JSON::Stream
- Psych::JSON::TreeBuilder
- Psych::Nodes
- Psych::Nodes::Alias
- Psych::Nodes::Document
- Psych::Nodes::Mapping
- Psych::Nodes::Node
- Psych::Nodes::Scalar
- Psych::Nodes::Sequence
- Psych::Nodes::Stream
- Psych::Omap
- Psych::Parser
- Psych::Parser::Mark
- Psych::ScalarScanner
- Psych::Set
- Psych::Stream
- Psych::Streaming
- Psych::Streaming::ClassMethods
- Psych::SyntaxError
- Psych::TreeBuilder
- Psych::Visitors
- Psych::Visitors::DepthFirst
- Psych::Visitors::Emitter
- Psych::Visitors::JSONTree
- Psych::Visitors::NoAliasRuby
- Psych::Visitors::ToRuby
- Psych::Visitors::Visitor
- Psych::Visitors::YAMLTree
- Regexp

No matching classes.

# 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() click to toggle source

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

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

### Public Instance Methods

alias?() click to toggle source

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

document?() click to toggle source

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

each(&block) click to toggle source

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

                   # File 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?() click to toggle source

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

scalar?() click to toggle source

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

sequence?() click to toggle source

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

stream?() click to toggle source

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

to_ruby() click to toggle source

Convert this node to Ruby.

See also `Psych::Visitors::ToRuby`

                   # File psych/lib/psych/nodes/node.rb, line 49
    def to_ruby
      Visitors::ToRuby.create.accept(self)
    end

Also aliased as: transform
to_yaml(io = nil, options = {}) click to toggle source
Alias for: yaml
transform() click to toggle source
Alias for: to_ruby
yaml(io = nil, options = {}) click to toggle source

Convert this node to YAML.

See also `Psych::Visitors::Emitter`

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

Also aliased as: to_yaml