summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/psych/visitors/to_ruby.rb1
-rw-r--r--test/visitors/test_to_ruby.rb5
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb
index 7cfe333..6aea934 100644
--- a/lib/psych/visitors/to_ruby.rb
+++ b/lib/psych/visitors/to_ruby.rb
@@ -15,6 +15,7 @@ module Psych
return o.value if ['!str', 'tag:yaml.org,2002:str'].include?(o.tag)
return Complex(o.value) if o.tag == "!ruby/object:Complex"
+ return Rational(o.value) if o.tag == "!ruby/object:Rational"
return o.value if o.quoted
token = ScalarScanner.new(o.value).tokenize
diff --git a/test/visitors/test_to_ruby.rb b/test/visitors/test_to_ruby.rb
index 3cb1ead..63a5006 100644
--- a/test/visitors/test_to_ruby.rb
+++ b/test/visitors/test_to_ruby.rb
@@ -45,6 +45,11 @@ module Psych
node = Nodes::Scalar.new '3+4i', nil, "!ruby/object:Complex"
assert_equal Complex(3, 4), node.to_ruby
end
+
+ def test_rational_string
+ node = Nodes::Scalar.new '1/2', nil, "!ruby/object:Rational"
+ assert_equal Rational(1, 2), node.to_ruby
+ end
end
def test_integer