Class: Cities::City
- Inherits:
-
Object
- Object
- Cities::City
- Defined in:
- lib/cities/city.rb
Instance Method Summary collapse
-
#initialize(data) ⇒ City
constructor
A new instance of City.
- #latitude ⇒ Object
- #latlong ⇒ Object
- #latlong? ⇒ Boolean
- #longitude ⇒ Object
- #name ⇒ Object
- #population ⇒ Object
- #region ⇒ Object
Constructor Details
#initialize(data) ⇒ City
Returns a new instance of City.
5 6 7 |
# File 'lib/cities/city.rb', line 5 def initialize(data) @data = data end |
Instance Method Details
#latitude ⇒ Object
13 14 15 16 |
# File 'lib/cities/city.rb', line 13 def latitude return nil if @data['latitude'].nil? @data['latitude'].to_f end |
#latlong ⇒ Object
27 28 29 |
# File 'lib/cities/city.rb', line 27 def latlong latlong? ? [latitude, longitude] : nil end |
#latlong? ⇒ Boolean
23 24 25 |
# File 'lib/cities/city.rb', line 23 def latlong? latitude && longitude end |
#longitude ⇒ Object
18 19 20 21 |
# File 'lib/cities/city.rb', line 18 def longitude return nil if @data['longitude'].nil? @data['longitude'].to_f end |
#name ⇒ Object
9 10 11 |
# File 'lib/cities/city.rb', line 9 def name @data['accentcity'] end |
#population ⇒ Object
31 32 33 34 |
# File 'lib/cities/city.rb', line 31 def population return nil if @data['population'].nil? @data['population'].to_i end |
#region ⇒ Object
36 37 38 |
# File 'lib/cities/city.rb', line 36 def region @data['region'] end |