Module: ISO4217::CurrencyHelper

Defined in:
lib/iso4217/iso4217.rb,
lib/iso4217/currencies.rb

Constant Summary collapse

COUNTRIES =
{
  :AF => AFGHAN_AFGHANI,
  :AX => EURO,
  :AL => ALBANIAN_LEK,
  :DZ => ALGERIAN_DINAR,
  :AS => UNITED_STATES_DOLLAR,
  :AD => EURO,
  :AO => ANGOLAN_KWANZA,
  :AI => EAST_CARIBBEAN_DOLLAR,
  :AG => EAST_CARIBBEAN_DOLLAR,
  :AR => ARGENTINE_PESO,
  :AM => ARMENIAN_DRAM,
  :AW => ARUBAN_FLORIN,
  :AU => AUSTRALIAN_DOLLAR,
  :AT => EURO,
  :AZ => AZERBAIJANI_MANAT,
  :BS => BAHAMIAN_DOLLAR,
  :BH => BAHRAINI_DINAR,
  :BD => BANGLADESHI_TAKA,
  :BB => BARBADIAN_DOLLAR,
  :BY => BELARUSIAN_RUBLE,
  :BE => EURO,
  :BZ => BELIZE_DOLLAR,
  :BJ => WEST_AFRICAN_CFA_FRANC,
  :BM => BERMUDIAN_DOLLAR,
  :BT => INDIAN_RUPEE,
  :BO => BOLIVIAN_BOLIVIANO,
  :BA => BOSNIA_AND_HERZEGOVINA_CONVERTIBLE_MARK,
  :BW => BOTSWANA_PULA,
  :BV => NORWEGIAN_KRONE,
  :BR => BRAZILIAN_REAL,
  :IO => UNITED_STATES_DOLLAR,
  :BN => BRUNEI_DOLLAR,
  :BG => BULGARIAN_LEV,
  :BF => WEST_AFRICAN_CFA_FRANC,
  :BI => BURUNDIAN_FRANC,
  :KH => CAMBODIAN_RIEL,
  :CM => CENTRAL_AFRICAN_CFA_FRANC,
  :CA => CANADIAN_DOLLAR,
  :CV => CAPE_VERDEAN_ESCUDO,
  :KY => CAYMAN_ISLANDS_DOLLAR,
  :CF => CENTRAL_AFRICAN_CFA_FRANC,
  :TD => CENTRAL_AFRICAN_CFA_FRANC,
  :CL => CHILEAN_PESO,
  :CN => CHINESE_RENMINBI_YUAN,
  :CX => AUSTRALIAN_DOLLAR,
  :CC => AUSTRALIAN_DOLLAR,
  :CO => COLOMBIAN_PESO,
  :KM => COMORIAN_FRANC,
  :CG => CENTRAL_AFRICAN_CFA_FRANC,
  :CD => CONGOLESE_FRANC,
  :CK => NEW_ZEALAND_DOLLAR,
  :CR => COSTA_RICAN_COLON,
  :CI => WEST_AFRICAN_CFA_FRANC,
  :HR => CROATIAN_KUNA,
  :CU => CUBAN_PESO,
  :CY => EURO,
  :CZ => CZECH_KORUNA,
  :DK => DANISH_KRONE,
  :DJ => DJIBOUTIAN_FRANC,
  :DM => EAST_CARIBBEAN_DOLLAR,
  :DO => DOMINICAN_PESO,
  :EC => UNITED_STATES_DOLLAR,
  :EG => EGYPTIAN_POUND,
  :SV => SALVADORAN_COLON,
  :GQ => CENTRAL_AFRICAN_CFA_FRANC,
  :ER => ERITREAN_NAKFA,
  :EE => ESTONIAN_KROON,
  :ET => ETHIOPIAN_BIRR,
  :FK => FALKLAND_POUND,
  :FO => DANISH_KRONE,
  :FJ => FIJIAN_DOLLAR,
  :FI => EURO,
  :FR => EURO,
  :GF => EURO,
  :PF => CFP_FRANC,
  :TF => EURO,
  :GA => CENTRAL_AFRICAN_CFA_FRANC,
  :GM => GAMBIAN_DALASI,
  :GE => GEORGIAN_LARI,
  :DE => EURO,
  :GH => GHANAIAN_CEDI,
  :GI => GIBRALTAR_POUND,
  :GR => EURO,
  :GL => DANISH_KRONE,
  :GD => EAST_CARIBBEAN_DOLLAR,
  :GP => EURO,
  :GU => UNITED_STATES_DOLLAR,
  :GT => GUATEMALAN_QUETZAL,
  :GG => BRITISH_POUND,
  :GN => GUINEAN_FRANC,
  :GW => WEST_AFRICAN_CFA_FRANC,
  :GY => GUYANESE_DOLLAR,
  :HT => HAITIAN_GOURDE,
  :HM => AUSTRALIAN_DOLLAR,
  :VA => EURO,
  :HN => HONDURAN_LEMPIRA,
  :HK => HONG_KONG_DOLLAR,
  :HU => HUNGARIAN_FORINT,
  :IS => ICELANDIC_KRONA,
  :IN => INDIAN_RUPEE,
  :ID => INDONESIAN_RUPIAH,
  :IR => IRANIAN_RIAL,
  :IQ => IRAQI_DINAR,
  :IE => EURO,
  :IM => BRITISH_POUND,
  :IL => ISRAELI_NEW_SHEQEL,
  :IT => EURO,
  :JM => JAMAICAN_DOLLAR,
  :JP => JAPANESE_YEN,
  :JE => BRITISH_POUND,
  :JO => JORDANIAN_DINAR,
  :KZ => KAZAKHSTANI_TENGE,
  :KE => KENYAN_SHILLING,
  :KI => AUSTRALIAN_DOLLAR,
  :KP => NORTH_KOREAN_WON,
  :KR => SOUTH_KOREAN_WON,
  :KW => KUWAITI_DINAR,
  :KG => KYRGYZSTANI_SOM,
  :LA => LAO_KIP,
  :LV => LATVIAN_LATS,
  :LB => LEBANESE_LIRA,
  :LS => SOUTH_AFRICAN_RAND,
  :LR => LIBERIAN_DOLLAR,
  :LY => LIBYAN_DINAR,
  :LI => SWISS_FRANC,
  :LT => LITHUANIAN_LITAS,
  :LU => EURO,
  :MO => MACANESE_PATACA,
  :MK => MACEDONIAN_DENAR,
  :MG => MALAGASY_ARIARY,
  :MW => MALAWIAN_KWACHA,
  :MY => MALAYSIAN_RINGGIT,
  :MV => MALDIVIAN_RUFIYAA,
  :ML => WEST_AFRICAN_CFA_FRANC,
  :MT => EURO,
  :MH => UNITED_STATES_DOLLAR,
  :MQ => EURO,
  :MR => MAURITANIAN_OUGUIYA,
  :MU => MAURITIAN_RUPEE,
  :YT => EURO,
  :MX => MEXICAN_PESO,
  :FM => UNITED_STATES_DOLLAR,
  :MD => MOLDOVAN_LEU,
  :MC => EURO,
  :MN => MONGOLIAN_TOGROG,
  :ME => EURO,
  :MS => EAST_CARIBBEAN_DOLLAR,
  :MA => MOROCCAN_DIRHAM,
  :MZ => MOZAMBICAN_METICAL,
  :MM => MYANMAR_KYAT,
  :NA => SOUTH_AFRICAN_RAND,
  :NR => AUSTRALIAN_DOLLAR,
  :NP => NEPALESE_RUPEE,
  :NL => EURO,
  :AN => NETHERLANDS_ANTILLEAN_GULDEN,
  :NC => CFP_FRANC,
  :NZ => NEW_ZEALAND_DOLLAR,
  :NI => NICARAGUAN_CORDOBA,
  :NE => WEST_AFRICAN_CFA_FRANC,
  :NG => NIGERIAN_NAIRA,
  :NU => NEW_ZEALAND_DOLLAR,
  :NF => AUSTRALIAN_DOLLAR,
  :MP => UNITED_STATES_DOLLAR,
  :NO => NORWEGIAN_KRONE,
  :OM => OMANI_RIAL,
  :PK => PAKISTANI_RUPEE,
  :PW => UNITED_STATES_DOLLAR,
  :PS => UNITED_STATES_DOLLAR,
  :PA => PANAMANIAN_BALBOA,
  :PG => PAPUA_NEW_GUINEAN_KINA,
  :PY => PARAGUAYAN_GUARANI,
  :PE => PERUVIAN_NUEVO_SOL,
  :PH => PHILIPPINE_PESO,
  :PN => NEW_ZEALAND_DOLLAR,
  :PL => POLISH_ZLOTY,
  :PT => EURO,
  :PR => UNITED_STATES_DOLLAR,
  :QA => QATARI_RIYAL,
  :RE => EURO,
  :RO => ROMANIAN_LEU,
  :RU => RUSSIAN_RUBLE,
  :RW => RWANDAN_FRANC,
  :BL => RWANDAN_FRANC,
  :SH => RWANDAN_FRANC,
  :KN => EAST_CARIBBEAN_DOLLAR,
  :LC => EAST_CARIBBEAN_DOLLAR,
  :MF => EURO,
  :PM => EURO,
  :VC => EAST_CARIBBEAN_DOLLAR,
  :WS => SAMOAN_TALA,
  :SM => EURO,
  :ST => EURO,
  :SA => SAUDI_RIYAL,
  :SN => WEST_AFRICAN_CFA_FRANC,
  :RS => SERBIAN_DINAR,
  :SC => SEYCHELLOIS_RUPEE,
  :SL => SIERRA_LEONEAN_LEONE,
  :SG => SINGAPORE_DOLLAR,
  :SK => EURO,
  :SI => EURO,
  :SB => SOLOMON_ISLANDS_DOLLAR,
  :SO => SOMALI_SHILLING,
  :ZA => SOUTH_AFRICAN_RAND,
  :GS => SOUTH_AFRICAN_RAND,
  :ES => EURO,
  :LK => SRI_LANKAN_RUPEE,
  :SD => SUDANESE_POUND,
  :SR => SURINAMESE_DOLLAR,
  :SJ => NORWEGIAN_KRONE,
  :SZ => SWAZI_LILANGENI,
  :SE => SWEDISH_KRONA,
  :CH => SWISS_FRANC,
  :SY => SYRIAN_POUND,
  :TW => NEW_TAIWAN_DOLLAR,
  :TJ => TAJIKISTANI_SOMONI,
  :TZ => TANZANIAN_SHILLING,
  :TH => THAI_BAHT,
  :TL => UNITED_STATES_DOLLAR,
  :TG => WEST_AFRICAN_CFA_FRANC,
  :TK => NEW_ZEALAND_DOLLAR,
  :TO => TONGAN_PAANGA,
  :TT => TRINIDAD_AND_TOBAGO_DOLLAR,
  :TN => TUNISIAN_DINAR,
  :TR => TURKISH_NEW_LIRA,
  :TM => TURKMENISTANI_MANAT,
  :TC => UNITED_STATES_DOLLAR,
  :TV => AUSTRALIAN_DOLLAR,
  :UG => UGANDAN_SHILLING,
  :UA => UKRAINIAN_HRYVNIA,
  :AE => UNITED_ARAB_EMIRATES_DIRHAM,
  :GB => BRITISH_POUND,
  :UK => BRITISH_POUND,
  :US => UNITED_STATES_DOLLAR,
  :UM => UNITED_STATES_DOLLAR,
  :UY => URUGUAYAN_PESO,
  :UZ => UZBEKISTANI_SOM,
  :VU => VANUATU_VATU,
  :VE => VENEZUELAN_BOLIVAR,
  :VN => VIETNAMESE_DONG,
  :VG => UNITED_STATES_DOLLAR,
  :VI => UNITED_STATES_DOLLAR,
  :WF => CFP_FRANC,
  :EH => MOROCCAN_DIRHAM,
  :YE => YEMENI_RIAL,
  :ZM => ZAMBIAN_KWACHA,
  :ZW => ZIMBABWEAN_DOLLAR
}

Instance Method Summary collapse

Instance Method Details

#currency(code) ⇒ Object



177
178
179
# File 'lib/iso4217/currencies.rb', line 177

def currency(code)
  CURRENCY_BY_CODE[code.to_s]
end

#currency_code_for(country_code, default_when_currency_not_found = :NAC) ⇒ Object



257
258
259
# File 'lib/iso4217/iso4217.rb', line 257

def currency_code_for(country_code, default_when_currency_not_found= :NAC)
  currency_for(country_code, default_when_currency_not_found).code.to_s
end

#currency_for(country_code, default_when_currency_not_found = :NAC) ⇒ Object



253
254
255
# File 'lib/iso4217/iso4217.rb', line 253

def currency_for(country_code, default_when_currency_not_found= :NAC)
  COUNTRIES[country_code] || Currency.new(default_when_currency_not_found, GENERIC_CURRENCY_SIGN, 'unknown')
end

#currency_sign_for(country_code, default_when_currency_not_found = :NAC) ⇒ Object



261
262
263
# File 'lib/iso4217/iso4217.rb', line 261

def currency_sign_for(country_code, default_when_currency_not_found= :NAC)
  currency_for(country_code, default_when_currency_not_found).sign
end