Class: CitiesInTurkey::City

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

Instance Method Summary collapse

Constructor Details

#initialize(name, alpha_2_code, towns) ⇒ City

Returns a new instance of City.



3
4
5
6
7
# File 'lib/cities_in_turkey/city.rb', line 3

def initialize(name, alpha_2_code, towns)
  @name = name
  @alpha_2_code = alpha_2_code
  @towns = towns
end

Instance Method Details

#alpha_2_codeObject



17
18
19
# File 'lib/cities_in_turkey/city.rb', line 17

def alpha_2_code
  @alpha_2_code
end

#nameObject



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

def name
  @name
end

#townsObject



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

def towns
  @towns.map { |town| Town.new(town['name'], town['districts']) }.to_a
end