Module: NaturalEarth::Subdivisions

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

Overview

Give access to the list of supported subdivisions

Class Method Summary collapse

Methods included from ISO3166

as_iso3166_1, as_iso3166_2

Class Method Details

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

Fetch information about a subdivision, as a NaturalEarth::Subdivision instance

Raises:

  • (KeyError)


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

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

  NaturalEarth::Subdivision.new(SUBDIVISIONS[normalize(iso3166)])
end

.supportedObject Also known as: keys

Return the list of supported subdivisions, as iso-3166-2 codes



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

def supported
  SUBDIVISIONS.keys
end

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

Check if a subdivision is supported

Returns:

  • (Boolean)


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

def supported?(iso3166)
  SUBDIVISIONS.key?(normalize(iso3166))
end