Class: Money::Converters::Converter
- Inherits:
-
Object
- Object
- Money::Converters::Converter
- Defined in:
- lib/money/converters/converter.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#from_subunits(subunits, currency) ⇒ Object
11 12 13 14 15 |
# File 'lib/money/converters/converter.rb', line 11 def from_subunits(subunits, currency) currency = Helpers.value_to_currency(currency) value = Helpers.value_to_decimal(subunits) / subunit_to_unit(currency) Money.new(value, currency) end |
#to_subunits(money) ⇒ Object
6 7 8 9 |
# File 'lib/money/converters/converter.rb', line 6 def to_subunits(money) raise ArgumentError, "money cannot be nil" if money.nil? (money.value * subunit_to_unit(money.currency)).to_i end |