class Zomato2::City

Attributes

country_id[R]
country_name[R]
discovery_enabled[R]
has_new_ad_format[R]
id[R]
is_state[R]
name[R]
state_code[R]
state_id[R]
state_name[R]

Public Class Methods

new(zom_conn, attributes) click to toggle source
Calls superclass method
# File lib/zomato2/city.rb, line 7
def initialize(zom_conn, attributes)
  super(zom_conn)
  @id = attributes['id']
  @name = attributes['name']
  @country_id = attributes['country_id']
  @country_name = attributes['country_name']
  @is_state = attributes['is_state'] != 0
  @state_id = attributes['state_id']
  @state_name = attributes['state_name']
  @state_code = attributes['state_code']
  @discovery_enabled = attributes['discovery_enabled']
  @has_new_ad_format = attributes['has_new_ad_format']
end

Public Instance Methods

collections(start: nil, count: nil) click to toggle source
# File lib/zomato2/city.rb, line 23
def collections(start: nil, count: nil)
  q = {city_id: @id }
  q[:start] = start if start
  q[:count] = count if count
  results = get('collections', q)
  results['collections'].map { |c| Collection.new(@zom_conn, @id, c['collection']) }
end
cuisines(start: nil, count: nil) click to toggle source

alias :super_get :get

# File lib/zomato2/city.rb, line 40
def cuisines(start: nil, count: nil)
  q = {city_id: @id }
  q[:start] = start if start
  q[:count] = count if count
  results = get('cuisines', q)
  results['cuisines'].map { |c| Cuisine.new(@zom_conn, @id, c['cuisine']) }
end
establishments(start: nil, count: nil) click to toggle source
# File lib/zomato2/city.rb, line 31
def establishments(start: nil, count: nil)
  q = {city_id: @id }
  q[:start] = start if start
  q[:count] = count if count
  results = get('establishments', q)
  results['establishments'].map { |e| Establishment.new(@zom_conn, @id, e['establishment']) }
end
restaurants(start: nil, count: nil) click to toggle source
# File lib/zomato2/city.rb, line 48
def restaurants(start: nil, count: nil)
  q = {entity_type: 'city', entity_id: @id }  # 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
to_s() click to toggle source
Calls superclass method
# File lib/zomato2/city.rb, line 21
def to_s; super; end