Class: Zomato::Zone
- Inherits:
-
Object
- Object
- Zomato::Zone
- Defined in:
- lib/zomato/zone.rb
Instance Attribute Summary collapse
-
#city_id ⇒ Object
readonly
Returns the value of attribute city_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Zone
constructor
A new instance of Zone.
- #restaurants ⇒ Object
- #subzones ⇒ Object
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_id ⇒ Object (readonly)
Returns the value of attribute city_id.
4 5 6 |
# File 'lib/zomato/zone.rb', line 4 def city_id @city_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/zomato/zone.rb', line 4 def id @id end |
#name ⇒ Object (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
#restaurants ⇒ Object
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 |
#subzones ⇒ Object
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 |