class Psych::Nodes::Node
YAML 解析树中任何 Node 的基类。此类永远不应被实例化。
属性
此节点的子节点
此节点结束的列号
此节点结束的行号
此节点开始的列号
此节点开始的行号
关联的标签
Public Class Methods
Source
# File ext/psych/lib/psych/nodes/node.rb, line 32 def initialize @children = [] end
创建一个新的 Psych::Nodes::Node
Public Instance Methods
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
遍历树中的每个节点。以深度优先的方式将每个节点交给 block。
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
将此节点转换为 Ruby。
也别名为: transform
的别名: to_ruby
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
将此节点转换为 YAML。
也别名为: to_yaml