Class: Munificent::Currency

Inherits:
Object
  • Object
show all
Defined in:
app/models/munificent/currency.rb

Constant Summary collapse

SYMBOL_MAP =
{
  "GBP" => "£",
  "USD" => "$",
  "EUR" => "",
  "AUD" => "$",
  "CAD" => "$",
}.freeze
SUPPORTED_CURRENCIES =
SYMBOL_MAP.keys.freeze
SUPPORTED_CURRENCY_SYMBOLS =
SYMBOL_MAP.values.uniq.freeze
DEFAULT_CURRENCY =
"GBP".freeze

Class Method Summary collapse

Class Method Details

.present_allObject



17
18
19
20
21
# File 'app/models/munificent/currency.rb', line 17

def present_all
  SYMBOL_MAP.each.with_object({}) do |(iso_code, symbol), hash|
    hash["#{iso_code} (#{symbol})"] = iso_code.upcase
  end
end

.supported?(iso_code) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/munificent/currency.rb', line 23

def supported?(iso_code)
  SUPPORTED_CURRENCIES.include?(iso_code.upcase)
end