Sha256: cccf1de427b9759ab3dc50144a39d43b7c9d0180afcbae075052a71f223b3790

Contents?: true

Size: 1.14 KB

Versions: 11

Compression:

Stored size: 1.14 KB

Contents

require 'genesis_ruby/api/constants/currencies/iso4217'
require 'genesis_ruby/utils/money/conversions/amount_to_exponent'
require 'genesis_ruby/utils/money/conversions/exponent_to_amount'
require 'genesis_ruby/utils/money/format'

module GenesisRuby
  module Utils
    # Money Helper
    class MoneyFormat

      class << self

        # Convert major to minor currency format units
        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

        # Convert minor to major currency format units
        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

      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
genesis_ruby-0.2.0 lib/genesis_ruby/utils/money_format.rb
genesis_ruby-0.1.9 lib/genesis_ruby/utils/money_format.rb
genesis_ruby-0.1.8 lib/genesis_ruby/utils/money_format.rb
genesis_ruby-0.1.7 lib/genesis_ruby/utils/money_format.rb
genesis_ruby-0.1.6 lib/genesis_ruby/utils/money_format.rb
genesis_ruby-0.1.5 lib/genesis_ruby/utils/money_format.rb
genesis_ruby-0.1.4 lib/genesis_ruby/utils/money_format.rb
genesis_ruby-0.1.3 lib/genesis_ruby/utils/money_format.rb
genesis_ruby-0.1.2 lib/genesis_ruby/utils/money_format.rb
genesis_ruby-0.1.1 lib/genesis_ruby/utils/money_format.rb
genesis_ruby-0.1.0 lib/genesis_ruby/utils/money_format.rb