Class: Float

Inherits:
Object
  • Object
show all
Defined in:
lib/money/core_extensions.rb

Instance Method Summary collapse

Instance Method Details

#to_money(precision = nil) ⇒ Object

Convert the float to a Money object.

3.75.to_money     #=> #<Money @cents=375>

It takes an optional precision, which defaults to 2 or the number of digits after the decimal point if it’s more than 2.



19
20
21
# File 'lib/money/core_extensions.rb', line 19

def to_money(precision = nil)
  to_s.to_money(precision)
end