Sha256: 3149606b9b741822816d4a79cf997ee36507764e08e596e269d7ba9f10c7833f
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
require 'stringio' module Psych module Nodes ### # The base class for any Node in a YAML parse tree. This class should # never be instantiated. class Node include Enumerable # The children of this node attr_reader :children # An associated tag attr_reader :tag # Create a new Psych::Nodes::Node def initialize @children = [] end ### # Iterate over each node in the tree. Yields each node to +block+ depth # first. def each &block return enum_for :each unless block_given? Visitors::DepthFirst.new(block).accept self end ### # Convert this node to Ruby. # # See also Psych::Visitors::ToRuby def to_ruby Visitors::ToRuby.new.accept self end alias :transform :to_ruby ### # Convert this node to YAML. # # See also Psych::Visitors::Emitter def to_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 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
psych-1.2.2.rc1 | lib/psych/nodes/node.rb |
psych-1.2.1 | lib/psych/nodes/node.rb |