Sha256: eaede5fecf3a493a386216bdf67cba1562ecafeaf35d424444a542ba113c54b0
Contents?: true
Size: 542 Bytes
Versions: 2
Compression:
Stored size: 542 Bytes
Contents
class Numeric # Converts this numeric to a Money object in the default currency. It # multiplies the numeric value by 100 and treats that as cents. # # NOTE!!! # This is overriden as per the default Money .to_money because it assumes # a different default currency... # # 100.to_money => #<Money @cents=10000> # 100.37.to_money => #<Money @cents=10037> # require 'bigdecimal' # BigDecimal.new('100').to_money => #<Money @cents=10000> def to_money(currency = nil) ::Money.new((self * 100).round, currency) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
money_extensions-0.1.0 | lib/money_extensions/numeric.rb |
money_extensions-0.0.2 | lib/money_extensions/numeric.rb |