Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/more_money/core_extensions.rb
Overview
Allows Writing of 100.to_money for Numeric types
100.to_money => #<Money @cents=10000>
100.37.to_money => #<Money @cents=10037>
Instance Method Summary collapse
Instance Method Details
#to_money(currency = nil) ⇒ Object
6 7 8 9 |
# File 'lib/more_money/core_extensions.rb', line 6 def to_money(currency = nil) args = [(self * 100), currency].compact Money.new(*args) end |
#to_price(opts = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/more_money/core_extensions.rb', line 11 def to_price(opts = {}) money = to_money(opts[:currency]) args = [opts[:tax_code], opts[:tax_inclusive]].compact Price.new(money.cents, money.currency, *args) end |