Class: Zomato2::Category

Inherits:
EntityBase show all
Defined in:
lib/zomato2/category.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from EntityBase

#get

Constructor Details

#initialize(zom_conn, attributes) ⇒ Category

Returns a new instance of Category.



6
7
8
9
10
# File 'lib/zomato2/category.rb', line 6

def initialize(zom_conn, attributes)
  super(zom_conn)
  @id = attributes['id']
  @name = attributes['name']
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/zomato2/category.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/zomato2/category.rb', line 4

def name
  @name
end

Instance Method Details

#restaurants(start: nil, count: nil) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/zomato2/category.rb', line 14

def restaurants(start: nil, count: nil)
  q = {category_id: @id }
  q[:start] = start if start
  q[:count] = count if count
  results = get('search', q)
  results['restaurants'].map { |e| Restaurant.new(@zom_conn, e['restaurant']) }
end

#to_sObject



12
# File 'lib/zomato2/category.rb', line 12

def to_s; super; end