summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2009-09-28 11:40:04 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2009-09-28 11:40:04 -0700
commit49fca7804e07247adff31d00f90e98004ccf0f33 (patch)
treee7fc2686417641ca9a1ade0c0cbcc56366222f73
parentf3fcb96084fd7edf69bcd23e7d1dd3887794858c (diff)
downloadpsych-49fca7804e07247adff31d00f90e98004ccf0f33.zip
adding to_ruby
-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