Class: WorldDb::Model::CitySerializer

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

Overview

todo/check:

add as_row to CityBase for all classes - why? why not??

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(city) ⇒ CitySerializer

Returns a new instance of CitySerializer.



11
12
13
# File 'lib/worlddb/serializers/city.rb', line 11

def initialize( city )
  @city = city
end

Instance Attribute Details

#cityObject (readonly)

Returns the value of attribute city.



15
16
17
# File 'lib/worlddb/serializers/city.rb', line 15

def city
  @city
end

Instance Method Details

#as_rowObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/worlddb/serializers/city.rb', line 17

def as_row

  ## add virtual column like kind for metro, metro|city, city, district

  ## todo add region.title if present
  ## todo add metro.name if available - why? why not??

  data = { key:      city.key,
           name:     city.name,
           code:     city.code,
           pop:      city.pop,
           area:     city.area,
           synonyms: city.synonyms,
           country:  city.country.name }
  data
end