Class: GenesisRuby::Utils::Money::Conversions::ExponentToAmount

Inherits:
Base::Strategy
  • Object
show all
Defined in:
lib/genesis_ruby/utils/money/conversions/exponent_to_amount.rb

Overview

Amount To Exponent Money Conversion Strategy

Instance Attribute Summary

Attributes inherited from Base::Strategy

#amount, #currency, #currency_exponent

Instance Method Summary collapse

Methods inherited from Base::Strategy

#initialize

Constructor Details

This class inherits a constructor from GenesisRuby::Utils::Money::Base::Strategy

Instance Method Details

#convertObject

Convert ISO-4217 minor currency unit to amount



13
14
15
16
17
18
# File 'lib/genesis_ruby/utils/money/conversions/exponent_to_amount.rb', line 13

def convert
  format(
    "%.#{currency_exponent}f",
    (amount / parse_amount(10**currency_exponent)).truncate(currency_exponent)
  )
end