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')})}
@@eu_codes =

CSV Tabelle der Europäischen Länder Lnd;Kfz;Sprache;ISO-Code;Kurzbez;Bezeichnung;Nationalität;Bezeichnung lang

::CSV.read("#{File.dirname(File.expand_path(__FILE__))}/csv_country_selector/eu_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



34
35
36
# File 'lib/csv_country_selector.rb', line 34

def self.codes
  @@codes
end

.is_in_eu?(country_short_name) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/csv_country_selector.rb', line 38

def self.is_in_eu?(country_short_name)
  @@eu_codes.values.include?(country_short_name)
end

.long_listObject



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

def self.long_list
  @@codes.values
end

.long_name_for(name) ⇒ Object



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

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

.short_listObject



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

def self.short_list
  @@codes.values
end

.short_name_for(name) ⇒ Object



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

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