Class: GenesisRuby::Utils::Formatters::Response::Formats::Amount

Inherits:
Base
  • Object
show all
Defined in:
lib/genesis_ruby/utils/formatters/response/formats/amount.rb

Overview

Response Amount Formatter. Converts Minor Currency to Major currency format

Instance Method Summary collapse

Methods inherited from Base

#collect_required_key_values

Instance Method Details

#format_key(amount, currency) ⇒ Object

Format the given amount response key and its currency to major currency format



25
26
27
28
29
# File 'lib/genesis_ruby/utils/formatters/response/formats/amount.rb', line 25

def format_key(amount, currency)
  GenesisRuby::Utils::MoneyFormat.exponent_to_amount(amount, currency)
rescue StandardError
  amount
end

#formatting_keysObject

The Response keys that the formatter will be applied to



15
16
17
# File 'lib/genesis_ruby/utils/formatters/response/formats/amount.rb', line 15

def formatting_keys
  %w(amount leftover_amount)
end

#required_keysObject

The keys required for formatting the specific response key



20
21
22
# File 'lib/genesis_ruby/utils/formatters/response/formats/amount.rb', line 20

def required_keys
  %w(currency)
end