From 5ba05758fe549404a5b64fba6418278d16be8cec Mon Sep 17 00:00:00 2001 From: mrkn Date: Tue, 26 Jul 2011 15:40:27 +0000 Subject: * ext/bigdecimal/lib/bigdecimal/util.rb (BigDecimal#to_d): added for adapting other Numeric subclasses. [ruby-dev:44245] * test/bigdecimal/test_bigdecimal_util.rb: test for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/bigdecimal/lib/bigdecimal/util.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ext/bigdecimal/lib/bigdecimal') diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb index 6e1697be88..6860cfd702 100644 --- a/ext/bigdecimal/lib/bigdecimal/util.rb +++ b/ext/bigdecimal/lib/bigdecimal/util.rb @@ -54,6 +54,14 @@ class BigDecimal < Numeric i + "." + ("0"*(-z)) + f end end + + # call-seq: + # a.to_d -> bigdecimal + # + # Returns self. + def to_d + self + end end class Rational < Numeric -- cgit v1.2.3