summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/psych/nodes/node.rb4
-rw-r--r--test/visitors/test_to_ruby.rb1
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/psych/nodes/node.rb b/lib/psych/nodes/node.rb
index ce1bfe8..b5ae131 100644
--- a/lib/psych/nodes/node.rb
+++ b/lib/psych/nodes/node.rb
@@ -11,6 +11,10 @@ module Psych
def initialize
@children = []
end
+
+ def to_ruby
+ Visitors::ToRuby.new.accept self
+ end
end
end
end
diff --git a/test/visitors/test_to_ruby.rb b/test/visitors/test_to_ruby.rb
index 8cd29ac..0d2bbf4 100644
--- a/test/visitors/test_to_ruby.rb
+++ b/test/visitors/test_to_ruby.rb
@@ -11,6 +11,7 @@ module Psych
def test_scalar
scalar = Nodes::Scalar.new('foo')
assert_equal 'foo', @visitor.accept(scalar)
+ assert_equal 'foo', scalar.to_ruby
end
end
end