Module: Continent

Defined in:
lib/continent.rb

Class Method Summary collapse

Class Method Details

.by_alpha_2_code(country) ⇒ Object



9
10
11
# File 'lib/continent.rb', line 9

def self.by_alpha_2_code country
  self.data[:base][country]
end

.by_alpha_3_code(country) ⇒ Object



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

def self.by_alpha_3_code country
  self.data[:base][self.data[:by_alpha_3_code][country]]
end

.by_continent_code(continent) ⇒ Object



21
22
23
24
25
26
# File 'lib/continent.rb', line 21

def self.by_continent_code continent
  return nil unless self.data[:by_continent_code][continent]
  self.data[:by_continent_code][continent].map do |c|
    self.data[:base][c]
  end
end

.by_numeric_code(country) ⇒ Object



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

def self.by_numeric_code country
  self.data[:base][self.data[:by_numeric_code][country]]
end

.continent_name(continent) ⇒ Object



28
29
30
# File 'lib/continent.rb', line 28

def self.continent_name continent
  self.data[:continent_names][continent]
end

.dataObject



4
5
6
7
# File 'lib/continent.rb', line 4

def self.data
  @@data ||= YAML.load_file(File.join(File.dirname(__FILE__), '..', 'share',
    'data.yml'))
end