Class: Zomato::Zone

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Zone

Returns a new instance of Zone.



12
13
14
15
16
# File 'lib/zomato/zone.rb', line 12

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

Instance Attribute Details

#city_idObject (readonly)

Returns the value of attribute city_id.



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

def city_id
  @city_id
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.build(response) ⇒ Object



6
7
8
9
10
# File 'lib/zomato/zone.rb', line 6

def self.build(response)
  response['zones'].collect do |zone|
    Zone.new(zone['zone'])
  end
end

Instance Method Details

#restaurantsObject



23
24
25
26
27
# File 'lib/zomato/zone.rb', line 23

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

#subzonesObject



18
19
20
21
# File 'lib/zomato/zone.rb', line 18

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