Class: Cities::City

Inherits:
Object
  • Object
show all
Defined in:
lib/cities/city.rb

Instance Method Summary collapse

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

#latitudeObject



13
14
15
16
# File 'lib/cities/city.rb', line 13

def latitude
  return nil if @data['latitude'].nil?
  @data['latitude'].to_f
end

#latlongObject



27
28
29
# File 'lib/cities/city.rb', line 27

def latlong
  latlong? ? [latitude, longitude] : nil
end

#latlong?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/cities/city.rb', line 23

def latlong?
  latitude && longitude
end

#longitudeObject



18
19
20
21
# File 'lib/cities/city.rb', line 18

def longitude
  return nil if @data['longitude'].nil?
  @data['longitude'].to_f
end

#nameObject



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

def name
  @data['accentcity']
end

#populationObject



31
32
33
34
# File 'lib/cities/city.rb', line 31

def population
  return nil if @data['population'].nil?
  @data['population'].to_i
end

#regionObject



36
37
38
# File 'lib/cities/city.rb', line 36

def region
  @data['region']
end