Class: NaturalEarth::Country
- Inherits:
-
Object
- Object
- NaturalEarth::Country
- Defined in:
- lib/natural_earth/country.rb
Overview
A NaturalEarth country
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #continent ⇒ Object
- #geometry ⇒ Object
-
#initialize(data) ⇒ Country
constructor
A new instance of Country.
- #iso3166(format: 'alpha-2') ⇒ Object
- #name ⇒ Object
- #region ⇒ Object
- #subdivisions ⇒ Object
Constructor Details
#initialize(data) ⇒ Country
Returns a new instance of Country.
8 9 10 |
# File 'lib/natural_earth/country.rb', line 8 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/natural_earth/country.rb', line 6 def data @data end |
Instance Method Details
#continent ⇒ Object
20 21 22 |
# File 'lib/natural_earth/country.rb', line 20 def continent data['continent'] end |
#geometry ⇒ Object
32 33 34 |
# File 'lib/natural_earth/country.rb', line 32 def geometry Geometries.country(iso3166) end |
#iso3166(format: 'alpha-2') ⇒ Object
12 13 14 |
# File 'lib/natural_earth/country.rb', line 12 def iso3166(format: 'alpha-2') data.dig('iso-3166-1', format) end |
#name ⇒ Object
16 17 18 |
# File 'lib/natural_earth/country.rb', line 16 def name data['name'] end |
#region ⇒ Object
24 25 26 |
# File 'lib/natural_earth/country.rb', line 24 def region data['region'] end |
#subdivisions ⇒ Object
28 29 30 |
# File 'lib/natural_earth/country.rb', line 28 def subdivisions data['subdivisions'].each_with_object({}) { |iso3166, subs| subs[iso3166] = Subdivisions[iso3166] } end |