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 aa98fbb..cb7d363 100644
--- a/test/visitors/test_to_ruby.rb
+++ b/test/visitors/test_to_ruby.rb
@@ -10,6 +10,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