Class: Zomato::City

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ City

Returns a new instance of City.



17
18
19
20
21
22
23
24
# File 'lib/zomato/city.rb', line 17

def initialize(attributes)
  @id = attributes['id']
  @name = attributes['name']
  @longitude = attributes['longitude']
  @latitude = attributes['latitude']
  @has_nightlife = attributes['has_nightlife'] == 1
  @show_zones = attributes['show_zones'] == 1
end

Instance Attribute Details

#has_nightlifeObject (readonly)

Returns the value of attribute has_nightlife.



4
5
6
# File 'lib/zomato/city.rb', line 4

def has_nightlife
  @has_nightlife
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/zomato/city.rb', line 4

def id
  @id
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



4
5
6
# File 'lib/zomato/city.rb', line 4

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



4
5
6
# File 'lib/zomato/city.rb', line 4

def longitude
  @longitude
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/zomato/city.rb', line 4

def name
  @name
end

#show_zonesObject (readonly)

Returns the value of attribute show_zones.



4
5
6
# File 'lib/zomato/city.rb', line 4

def show_zones
  @show_zones
end

Class Method Details

.build(response) ⇒ Object



8
9
10
11
12
13
# File 'lib/zomato/city.rb', line 8

def build(response)
  @cities ||=
  response['cities'].collect do |city|
    City.new(city['city'])
  end
end

Instance Method Details

#cuisinesObject



42
43
44
45
46
47
48
# File 'lib/zomato/city.rb', line 42

def cuisines
  response = Api.get(
    '/cuisines', 
    :query => {:city_id => id}
  ).parsed_response
  Cuisine.build(response, id)
end

#localitiesObject



34
35
36
37
38
39
40
# File 'lib/zomato/city.rb', line 34

def localities
  response = Api.get(
    '/subzones', 
    :query => {:city_id => id}
  ).parsed_response
  Subzone.build(response, id)
end

#zonesObject



26
27
28
29
30
31
32
# File 'lib/zomato/city.rb', line 26

def zones
  response = Api.get(
    '/zones', 
    :query => {:city_id => id}
  ).parsed_response
  Zone.build(response)
end