Sha256: 4b34d7dddd03351c81c2aed64c3cbcaa1a147f58abf6a9d984ab73ab60157a7e
Contents?: true
Size: 492 Bytes
Versions: 2
Compression:
Stored size: 492 Bytes
Contents
class String # Converts this string to a float and then to a Money object in the default currency. # It multiplies the converted 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> def to_money(currency = nil) Money.new((self.to_f * 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/string.rb |
money_extensions-0.0.2 | lib/money_extensions/string.rb |