diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-30 10:46:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-30 10:46:06 +0000 |
commit | f1330fd12403ef4d664df7619d6ce312d525721a (patch) | |
tree | cfafd35d3d416b8529003d43db2ace98af20fdb1 /ext/psych/lib/psych/nodes/node.rb | |
parent | 38af94c6abaaa20aeaa1ffafbe3f6ff962f63eaa (diff) |
* ext/psych/lib: moved external library dependent files from lib.
[ruby-core:29129]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych/lib/psych/nodes/node.rb')
-rw-r--r-- | ext/psych/lib/psych/nodes/node.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ext/psych/lib/psych/nodes/node.rb b/ext/psych/lib/psych/nodes/node.rb new file mode 100644 index 0000000000..0de768c7ac --- /dev/null +++ b/ext/psych/lib/psych/nodes/node.rb @@ -0,0 +1,40 @@ +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 + # The children of this node + attr_reader :children + + # An associated tag + attr_reader :tag + + # Create a new Psych::Nodes::Node + def initialize + @children = [] + 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 = StringIO.new + Visitors::Emitter.new(io).accept self + io.string + end + end + end +end |