Class: CsvCountrySelector::Country

Inherits:
Object
  • Object
show all
Defined in:
lib/csv_country_selector.rb

Constant Summary collapse

@@codes =

CSV Tabelle als Masterfreferenz Lnd;Kfz;Sprache;ISO-Code;Kurzbez;Bezeichnung;Nationalität;Bezeichnung lang

::CSV.read("#{File.dirname(File.expand_path(__FILE__))}/csv_country_selector/countries.csv", :col_sep => ";").inject({}){|a,b| a.merge!({b[0].force_encoding('UTF-8') => b[5].force_encoding('UTF-8')})}

Class Method Summary collapse

Class Method Details

.codesObject



30
31
32
# File 'lib/csv_country_selector.rb', line 30

def self.codes
  @@codes
end

.long_listObject



22
23
24
# File 'lib/csv_country_selector.rb', line 22

def self.long_list
  @@codes.values
end

.long_name_for(name) ⇒ Object



18
19
20
# File 'lib/csv_country_selector.rb', line 18

def self.long_name_for(name)
  @@codes.select{|k,v| k.downcase == name.downcase}.try(:first).try(:last)
end

.short_listObject



26
27
28
# File 'lib/csv_country_selector.rb', line 26

def self.short_list
  @@codes.values
end

.short_name_for(name) ⇒ Object



13
14
15
# File 'lib/csv_country_selector.rb', line 13

def self.short_name_for(name)
  @@codes.select{|k,v| v.downcase == name.downcase}.try(:first).try(:first)
end