Class: Zomato2::Establishment

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

Overview

Restaurant types

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from EntityBase

#get, #to_s

Constructor Details

#initialize(zom_conn, cityid, attributes) ⇒ Establishment

Returns a new instance of Establishment.



7
8
9
10
11
12
# File 'lib/zomato2/establishment.rb', line 7

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

Instance Attribute Details

#city_idObject (readonly)

Returns the value of attribute city_id.



5
6
7
# File 'lib/zomato2/establishment.rb', line 5

def city_id
  @city_id
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/zomato2/establishment.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/zomato2/establishment.rb', line 5

def name
  @name
end

Instance Method Details

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



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/zomato2/establishment.rb', line 14

def restaurants(start: nil, count: nil)
  q = {establishment_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 do |e|
    r = Restaurant.new(@zom_conn, e['restaurant'])
    r.establishments = Array.new 
    r.establishments << self
    r
  end
end