Class: Zomato::Cuisine

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_idObject (readonly)

Returns the value of attribute city_id.



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

def city_id
  @city_id
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#nameObject (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