Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/money/core_extensions.rb
Instance Method Summary collapse
-
#to_money(precision = 2) ⇒ Object
Convert the number to a
Moneyobject.
Instance Method Details
#to_money(precision = 2) ⇒ Object
Convert the number to a Money object.
100.to_money #=> #<Money @cents=10000>
Takes an optional precision, which defaults to 2
7 8 9 |
# File 'lib/money/core_extensions.rb', line 7 def to_money(precision = 2) Money.new(self * 10**precision, Money.default_currency, precision) end |