Method: Numeric#to_money

Defined in:
lib/money/core_extensions.rb

#to_money(currency = nil) ⇒ Money

Converts this numeric into a Money object in the given currency.

Examples:

100.to_money                   #=> #<Money @cents=10000>
100.37.to_money                #=> #<Money @cents=10037>
BigDecimal.new('100').to_money #=> #<Money @cents=10000>

Parameters:

  • currency (Currency, String, Symbol) (defaults to: nil)

    The currency to set the resulting Money object to.

Returns:

See Also:



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

def to_money(currency = nil)
  Money.from_numeric(self, currency || Money.default_currency)
end