lib/flt/sugar.rb in flt-1.1.1 vs lib/flt/sugar.rb in flt-1.1.2

- old
+ new

@@ -98,5 +98,15 @@ instance_methods.each do |method| module_function method end end +# Shortcut to define DecNums, e.g. 1._234567890123456789 produces Flt::DecNum('1.234567890123456789') +# Based on http://coderrr.wordpress.com/2009/12/22/get-arbitrarily-precise-bigdecimals-in-ruby-for-just-one-extra-character/ +class Integer + def method_missing(m, *a, &b) + return Flt::DecNum("#{self}.#{$1.tr('_','')}") if m.to_s =~ /^_(\d[_\d]*)$/ + super + end +end + +