Class: Zomato::Cuisine
- Inherits:
-
Object
- Object
- Zomato::Cuisine
- Defined in:
- lib/zomato/cuisine.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) ⇒ Cuisine
constructor
A new instance of Cuisine.
- #restaurants(query = {}) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Cuisine
Returns a new instance of Cuisine.
14 15 16 17 18 |
# File 'lib/zomato/cuisine.rb', line 14 def initialize(attributes) @id = attributes['cuisine_id'].to_i @name = attributes['cuisine_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/cuisine.rb', line 4 def city_id @city_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/zomato/cuisine.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/zomato/cuisine.rb', line 4 def name @name end |
Class Method Details
.build(response, city_id) ⇒ Object
7 8 9 10 11 |
# File 'lib/zomato/cuisine.rb', line 7 def build(response, city_id) response["cuisines"].collect do |cuisine| Cuisine.new(cuisine['cuisine'].merge({'city_id' => city_id})) end end |
Instance Method Details
#restaurants(query = {}) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/zomato/cuisine.rb', line 20 def restaurants(query = {}) query = { :city_id => city_id, :cuisine_id => id }.merge(query) response = Api.get('/search', :query => query).parsed_response Restaurant.build(response, query) end |