diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-26 15:46:42 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-26 15:46:42 +0000 |
commit | 2fcb91c74c18680fed4c4067bda6aab60abb5de2 (patch) | |
tree | 0ab55df441bf98f3d51964045d4780fe82b2ce0d /ext | |
parent | 5ba05758fe549404a5b64fba6418278d16be8cec (diff) |
* ext/bigdecimal/lib/bigdecimal/util.rb (Integer#to_d): added
for symmetry to BigDecimal() function with an Integer.
fixes #5098. [ruby-dev:44210]
* test/bigdecimal/test_bigdecimal_util.rb: add test for the above
change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bigdecimal/lib/bigdecimal/util.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb index 6860cfd702..1ec39a30ee 100644 --- a/ext/bigdecimal/lib/bigdecimal/util.rb +++ b/ext/bigdecimal/lib/bigdecimal/util.rb @@ -1,3 +1,20 @@ +class Integer < Numeric + # call-seq: + # int.to_d -> bigdecimal + # + # Convert +int+ to a BigDecimal and return it. + # + # require 'bigdecimal' + # require 'bigdecimal/util' + # + # 42.to_d + # # => #<BigDecimal:1008ef070,'0.42E2',9(36)> + # + def to_d + BigDecimal(self) + end +end + class Float < Numeric # call-seq: # flt.to_d -> bigdecimal |