Permalink
Browse files

adding to_d to BigDecimal

  • Loading branch information...
1 parent e1a064a commit 2cb497b70c622039867d34a782d121d902325f4b @tenderlove tenderlove committed Jan 10, 2011
@@ -18,6 +18,10 @@ def to_yaml(opts = {})
end
end
+ def to_d
+ self
+ end
+
DEFAULT_STRING_FORMAT = 'F'
def to_formatted_s(format = DEFAULT_STRING_FORMAT)
_original_to_s(format)
@@ -7,4 +7,9 @@ def test_to_yaml
assert_equal("--- .NaN\n", BigDecimal.new('NaN').to_yaml)
assert_equal("--- -.Inf\n", BigDecimal.new('-Infinity').to_yaml)
end
-end
+
+ def test_to_d
+ bd = BigDecimal.new '10'
+ assert_equal bd, bd.to_d
+ end
+end

0 comments on commit 2cb497b

Please sign in to comment.