Class: Zomato2::Collection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from EntityBase

#get, #to_s

Constructor Details

#initialize(zom_conn, cityid, attributes) ⇒ Collection

Returns a new instance of Collection.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/zomato2/collection.rb', line 6

def initialize(zom_conn, cityid, attributes)
  super(zom_conn)
  @city_id = cityid
  @id  = attributes['collection_id']
  @url = attributes['url']
  @title  = attributes['title']
  @description = attributes['description']
  @image_url = attributes['image_url']
  @res_count = attributes['res_count']
  @share_url = attributes['share_url']
end

Instance Attribute Details

#city_idObject (readonly)

Returns the value of attribute city_id.



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

def city_id
  @city_id
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#image_urlObject (readonly)

Returns the value of attribute image_url.



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

def image_url
  @image_url
end

#res_countObject (readonly)

Returns the value of attribute res_count.



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

def res_count
  @res_count
end

#share_urlObject (readonly)

Returns the value of attribute share_url.



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

def share_url
  @share_url
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

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



18
19
20
21
22
23
24
# File 'lib/zomato2/collection.rb', line 18

def restaurants(start: nil, count: nil)
  q = {collection_id: @id, entity_type: 'city', entity_id: @city_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