Module: NaturalEarth::Countries

Extended by:
ISO3166
Defined in:
lib/natural_earth/countries.rb

Overview

Give access to the list of supported countries

Class Method Summary collapse

Methods included from ISO3166

as_iso3166_1, as_iso3166_2

Class Method Details

.fetch(iso3166_1) ⇒ Object Also known as: []

Fetch information about a country, as a NaturalEarth::Country instance

Raises:

  • (KeyError)


21
22
23
24
25
# File 'lib/natural_earth/countries.rb', line 21

def fetch(iso3166_1)
  raise KeyError unless supported?(iso3166_1)

  NaturalEarth::Country.new(COUNTRIES[normalize(iso3166_1)])
end

.supportedObject Also known as: keys

Return the list of supported countries as iso-3166-1 alpha-2 codes



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

def supported
  COUNTRIES.keys
end

.supported?(iso3166_1) ⇒ Boolean Also known as: key?

Check if a country is supported

Returns:

  • (Boolean)


16
17
18
# File 'lib/natural_earth/countries.rb', line 16

def supported?(iso3166_1)
  COUNTRIES.key?(normalize(iso3166_1))
end