Module: CountriesAndLanguages::Helpers

Defined in:
lib/countries_and_languages.rb

Instance Method Summary collapse

Instance Method Details

#countriesObject



6
7
8
9
# File 'lib/countries_and_languages.rb', line 6

def countries
  @@countries ||= {}
  @@countries[I18n.locale] ||= CountriesAndLanguages.clean_and_sort(I18nData.countries(I18n.locale.to_s.upcase))
end

#country(country_code) ⇒ Object



11
12
13
# File 'lib/countries_and_languages.rb', line 11

def country(country_code)
  (countries.rassoc(country_code.to_s.upcase) || [''])[0]
end

#language(language_code) ⇒ Object



20
21
22
# File 'lib/countries_and_languages.rb', line 20

def language(language_code)
  (languages.rassoc(language_code.to_s.upcase) || [''])[0]
end

#languagesObject



15
16
17
18
# File 'lib/countries_and_languages.rb', line 15

def languages
  @@languages ||= {}
  @@languages[I18n.locale] ||= CountriesAndLanguages.clean_and_sort(I18nData.languages(I18n.locale.to_s.upcase))
end