Skip to content

Instantly share code, notes, and snippets.

View benkitzelman's full-sized avatar
🏠
Working from home

Ben Kitzelman benkitzelman

🏠
Working from home
  • Locomote
  • Melbourne, Australia
View GitHub Profile
@benkitzelman
benkitzelman / country_codes.rb
Created February 24, 2013 12:36
ISO_3166-1 country codes 2 char to 3 char mapping
module CountryCodes
class << self
def two_char_code_for(three_char_country_code)
if country = CODES[three_char_country_code.to_sym]
country[:two_char_code]
end
end
def three_char_code_for(two_char_country_code)
CODES.select {|k,v| v[:two_char_code].to_sym == two_char_country_code.upcase.to_sym}.keys.first