module CurrencySelect

Module for creating currency drop-downs.

Constants

CURRENCIES

Public Class Methods

currencies_array() click to toggle source

Returns a two-dimensional array with ISO codes and currency names for option tags.

In the outer array, there will be one element for each currency. Each element looks like this, containing a label and the ISO code:

“Afghan Afghani - AFN”, “AFN”

@return [Array]

# File lib/currency_select.rb, line 50
def currencies_array
  CURRENCIES
end
priority_currencies_array(currency_codes = []) click to toggle source

Returns an array with ISO codes and currency names for currency ISO codes passed as an argument

Example

priority_currencies_array([ "USD", "NOK" ])
# => [
#  ['United States Dollar - USD', 'USD' ],
#  ['Norwegian Kroner - NOK', 'NOK']
# ]

@return [Array]

# File lib/currency_select.rb, line 66
def priority_currencies_array(currency_codes = [])
  currency_codes.flat_map do |code|
    currencies_array.select { |currency| currency.last.to_s == code }
  end
end