Class: GenesisRuby::Utils::MoneyFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/genesis_ruby/utils/money_format.rb

Overview

Money Helper

Class Method Summary collapse

Class Method Details

.amount_to_exponent(amount, currency) ⇒ Object

Convert major to minor currency format units



16
17
18
19
20
21
22
23
24
# File 'lib/genesis_ruby/utils/money_format.rb', line 16

def amount_to_exponent(amount, currency)
  strategy = GenesisRuby::Utils::Money::Conversions::AmountToExponent.new(
    amount,
    currency,
    GenesisRuby::Api::Constants::Currencies::Iso4217.fetch_exponent(currency)
  )

  GenesisRuby::Utils::Money::Format.new(strategy).convert
end

.exponent_to_amount(amount, currency) ⇒ Object

Convert minor to major currency format units



27
28
29
30
31
32
33
34
35
# File 'lib/genesis_ruby/utils/money_format.rb', line 27

def exponent_to_amount(amount, currency)
  strategy = GenesisRuby::Utils::Money::Conversions::ExponentToAmount.new(
    amount,
    currency,
    GenesisRuby::Api::Constants::Currencies::Iso4217.fetch_exponent(currency)
  )

  GenesisRuby::Utils::Money::Format.new(strategy).convert
end