Class: Zomato::Subzone

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes, city_id) ⇒ Subzone

Returns a new instance of Subzone.



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

def initialize(attributes, city_id)
  @id = attributes['subzone_id']
  @name = attributes['name']
  @zone_id = attributes['zone_id'].to_i
  @city_id = city_id.to_i
end

Instance Attribute Details

#city_idObject (readonly)

Returns the value of attribute city_id.



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

def city_id
  @city_id
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#zone_idObject (readonly)

Returns the value of attribute zone_id.



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

def zone_id
  @zone_id
end

Class Method Details

.build(response, city_id) ⇒ Object



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

def build(response, city_id)
  @subzones ||=
  response['subzones'].collect do |subzone|
    Subzone.new(subzone['subzone'], city_id)
  end
end

Instance Method Details

#restaurantsObject



24
25
26
27
28
# File 'lib/zomato/subzone.rb', line 24

def restaurants
  query = {:city_id => city_id, :subzone_id => id}
  response = Api.get('/search', :query => query).parsed_response
  Restaurant.build(response, query)
end