Skip to content

Instantly share code, notes, and snippets.

@postmodern
Created March 20, 2010 00:17
Show Gist options
  • Save postmodern/338344 to your computer and use it in GitHub Desktop.
Save postmodern/338344 to your computer and use it in GitHub Desktop.
A module containing Country names and codes
# Country Code List: ISO 3166-1993 (E)
module Countries
Mexico = 'MX'
GuineaBissau = 'GW'
Afghanistan = 'AF'
Ethiopia = 'ET'
SyrianArabRepublic = 'SY'
SvalbardJanMayenIslands = 'SJ'
Tonga = 'TO'
Pakistan = 'PK'
Unknownorunspecifiedcountry = 'ZZ'
BritishVirginIslands = 'VG'
Somalia = 'SO'
Bolivia = 'BO'
NorthernMarianaIslands = 'MP'
Nicaragua = 'NI'
Dominica = 'DM'
Sweden = 'SE'
Greece = 'GR'
Micronesia = 'FM'
Guadeloupe = 'GP'
UnitedArabEmirates = 'AE'
Cambodia = 'KH'
Ireland = 'IE'
Vanuatu = 'VU'
FrenchGuiana = 'GF'
Denmark = 'DK'
Czechoslovakia = 'CS'
Norway = 'NO'
Gabon = 'GA'
Malawi = 'MW'
Djibouti = 'DJ'
Namibia = 'NA'
Samoa = 'WS'
WallisFutunaIslands = 'WF'
Switzerland = 'CH'
Chad = 'TD'
UnitedStatesVirginIslands = 'VI'
Bhutan = 'BT'
PuertoRico = 'PR'
Haiti = 'HT'
Tajikistan = 'TJ'
Guyana = 'GY'
Turkmenistan = 'TM'
Kuwait = 'KW'
Canada = 'CA'
France = 'FR'
DominicanRepublic = 'DO'
Venezuela = 'VE'
Belize = 'BZ'
Italy = 'IT'
Congo = 'CG'
Tokelau = 'TK'
Mayotte = 'YT'
Algeria = 'DZ'
Lebanon = 'LB'
Azerbaijan = 'AZ'
CocosIslands = 'CC'
FrenchSouthernTerritories = 'TF'
Israel = 'IL'
Nigeria = 'NG'
Austria = 'AT'
Hungary = 'HU'
SolomonIslands = 'SB'
China = 'CN'
SaudiArabia = 'SA'
Angola = 'AO'
Kazakhstan = 'KZ'
Guam = 'GU'
Peru = 'PE'
HongKong = 'HK'
Latvia = 'LV'
Bangladesh = 'BD'
GreatBritain = 'GB'
ChristmasIsland = 'CX'
CookIislands = 'CK'
Luxembourg = 'LU'
Bahrain = 'BH'
Malta = 'MT'
Colombia = 'CO'
Panama = 'PA'
Oman = 'OM'
Netherlands = 'NL'
Philippines = 'PH'
Burundi = 'BI'
StPierreMiquelon = 'PM'
Antarctica = 'AQ'
Germany = 'DE'
Macau = 'MO'
Armenia = 'AM'
Nepal = 'NP'
Pitcairn = 'PN'
Mauritius = 'MU'
BruneiDarussalam = 'BN'
Bulgaria = 'BG'
Indonesia = 'ID'
Tanzania = 'TZ'
MarshallIslands = 'MH'
AmericanSamoa = 'AS'
Lesotho = 'LS'
Slovakia = 'SK'
SouthGeorgiaandtheSouthSandwichIslands = 'GS'
PapuaNewGuinea = 'PG'
Jordan = 'JO'
Cyprus = 'CY'
NeutralZone = 'NT'
Burma = 'BU'
SierraLeone = 'SL'
Yemen = 'YE'
Ukraine = 'UA'
WesternSahara = 'EH'
Bermuda = 'BM'
Croatia = 'HR'
Aruba = 'AW'
Belgium = 'BE'
Liberia = 'LR'
Grenada = 'GD'
Monserrat = 'MS'
Thailand = 'TH'
FranceMetropolitan = 'FX'
Botswana = 'BW'
Cuba = 'CU'
Andorra = 'AD'
VaticanCityState = 'VA'
Estonia = 'EE'
EastTimor = 'TP'
BouvetIsland = 'BV'
EquatorialGuinea = 'GQ'
Tunisia = 'TN'
Togo = 'TG'
Sudan = 'SD'
NetherlandsAntilles = 'AN'
FaroeIslands = 'FO'
TurksCaicosIslands = 'TC'
Barbados = 'BB'
AntiguaBarbuda = 'AG'
Mauritania = 'MR'
Fiji = 'FJ'
BosniaandHerzegovina = 'BA'
Taiwan = 'TW'
StKittsandNevis = 'KN'
Comoros = 'KM'
BurkinaFaso = 'BF'
BritishIndianOceanTerritory = 'IO'
ElSalvador = 'SV'
Maldives = 'MV'
SaintLucia = 'LC'
Niue = 'NU'
Georgia = 'GE'
Zimbabwe = 'ZW'
Spain = 'ES'
Lao = 'LA'
Monaco = 'MC'
Martinique = 'MQ'
Uzbekistan = 'UZ'
CaymanIslands = 'KY'
Bahama = 'BS'
IslamicRepublicofIran = 'IR'
Zambia = 'ZM'
Uganda = 'UG'
Finland = 'FI'
Mongolia = 'MN'
Eritrea = 'ER'
Gibraltar = 'GI'
Portugal = 'PT'
Kiribati = 'KI'
Iraq = 'IQ'
Morocco = 'MA'
Argentina = 'AR'
Malaysia = 'MY'
India = 'IN'
Greenland = 'GL'
StVincentGrenadines = 'VC'
Egypt = 'EG'
Reunion = 'RE'
Australia = 'AU'
CzechRepublic = 'CZ'
Zaire = 'ZR'
VietNam = 'VN'
Suriname = 'SR'
NewZealand = 'NZ'
Honduras = 'HN'
NorfolkIsland = 'NF'
Guinea = 'GN'
Nauru = 'NR'
Belarus = 'BY'
Korea = 'KR'
UnitedStatesMinorOutlyingIslands = 'UM'
SanMarino = 'SM'
Yugoslavia = 'YU'
IvoryCoast = 'CI'
Swaziland = 'SZ'
Niger = 'NE'
Albania = 'AL'
StHelena = 'SH'
Mali = 'ML'
Slovenia = 'SI'
Poland = 'PL'
LibyanArabJamahiriya = 'LY'
Myanmar = 'MM'
Mozambique = 'MZ'
Japan = 'JP'
Kyrgyzstan = 'KG'
CapeVerde = 'CV'
SouthAfrica = 'ZA'
HeardMcDonaldIslands = 'HM'
Malvinas = 'FK'
Liechtenstein = 'LI'
Romania = 'RO'
Kenya = 'KE'
FrenchPolynesia = 'PF'
TrinidadTobago = 'TT'
NewCaledonia = 'NC'
Singapore = 'SG'
Tuvalu = 'TV'
Benin = 'BJ'
Ghana = 'GH'
Cameroon = 'CM'
Guatemala = 'GT'
Qatar = 'QA'
SriLanka = 'LK'
Madagascar = 'MG'
Turkey = 'TR'
Palau = 'PW'
Senegal = 'SN'
Chile = 'CL'
Gambia = 'GM'
Iceland = 'IS'
Uruguay = 'UY'
UnitedStatesofAmerica = 'US'
Ecuador = 'EC'
Brazil = 'BR'
SaoTome = 'ST'
Rwanda = 'RW'
RussianFederation = 'RU'
Jamaica = 'JM'
Anguilla = 'AI'
Paraguay = 'PY'
CostaRica = 'CR'
Seychelles = 'SC'
Lithuania = 'LT'
Moldova = 'MD'
CentralAfricanRepublic = 'CF'
#
# Iterates over every Country Code.
#
# @yield [country,code]
# The given block will receive every Country Name and Code.
#
# @yieldparam [String] country
# The name of the Country.
#
# @yieldparam [String] code
# The ISO 3166-1993 Country Code.
#
# @return [Countries]
# The Countries module.
#
def Countries.each(&block)
self.constants.each do |name|
block.call(name,self.const_get(name)) if block
end
return self
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment