Class: WorldDb::Model::CountrySerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/worlddb/serializers/country.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(country) ⇒ CountrySerializer

Returns a new instance of CountrySerializer.



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

def initialize( country )
  @country = country
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



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

def country
  @country
end

Instance Method Details

#as_rowObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/worlddb/serializers/country.rb', line 17

def as_row

  ## todo: add tags too??
  data = { key:      country.key,
           name:     country.name,
           code:     country.code,
           pop:      country.pop,
           area:     country.area,
           synonyms: country.synonyms }
   data
end