adding to_d to BigDecimal

This commit is contained in:
Aaron Patterson
2011-01-10 15:43:21 -08:00
parent f4f4964ce0
commit 1cc556dc52
2 changed files with 10 additions and 1 deletions

View File

@@ -18,6 +18,10 @@ class BigDecimal
end
end
def to_d
self
end
DEFAULT_STRING_FORMAT = 'F'
def to_formatted_s(format = DEFAULT_STRING_FORMAT)
_original_to_s(format)

View File

@@ -7,4 +7,9 @@ class BigDecimalTest < Test::Unit::TestCase
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