class Zomato2::Restaurant
Attributes
all_reviews_count[R]
average_cost_for_two[R]
city_id[R]
cuisines[R]
currency[R]
deeplink[R]
establishments[RW]
events_url[R]
featured_image[R]
has_online_delivery[R]
has_table_booking[R]
id[R]
is_delivering_now[R]
location[R]
name[R]
phone_numbers[R]
photo_count[R]
photos[R]
photos_url[R]
price_range[R]
reviews[RW]
thumb[R]
user_rating[R]
Public Class Methods
new(zom_conn, attributes)
click to toggle source
Calls superclass method
Zomato2::EntityBase::new
# File lib/zomato2/restaurant.rb, line 10 def initialize(zom_conn, attributes) super(zom_conn) @location = Location.new zom_conn, attributes["location"] @city_id = @location.city_id attributes.each do |k,v| if k == 'apikey' next elsif k == 'R' @id = v['res_id'] # Zomato never returns this?? bad API doc! elsif k == 'location' next elsif k == 'all_reviews' @reviews = v.map{ |r| Review.new(zom_conn, r) } elsif k == 'establishment_types' @establishments = v.map{ |e,ev| Establishment.new(zom_conn, @city_id, ev) } # elsif k == 'cuisines' the returned cuisines here are just a string.. else #puts "ATTR @#{k} val #{v}" self.instance_variable_set("@#{k}", v) end end end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/zomato2/restaurant.rb, line 41 def <=>(other) @id <=> other.id end
==(other)
click to toggle source
# File lib/zomato2/restaurant.rb, line 37 def ==(other) @id == other.id and @name == other.name and @city_id == other.city_id # ... end
details(start: nil, count: nil)
click to toggle source
this doesn't actually give any more detailed info..
# File lib/zomato2/restaurant.rb, line 55 def details(start: nil, count: nil) # warn "\tRestaurant#details: This method is currently useless, since, " + # "as of January 2017, Zomato's API doesn't give any additional info here." q = {res_id: @id } q[:start] = start if start q[:count] = count if count results = get('restaurant', q) @location ||= Location.new zom_conn, attributes["location"] @city_id ||= @location.city_id results.each do |k,v| if k == 'apikey' next elsif k == 'R' @id = v['res_id'] # Zomato never returns this?? bad API doc! elsif k == 'location' next elsif k == 'all_reviews' @reviews ||= v.map{ |r| Review.new(zom_conn, r) } elsif k == 'establishment_types' @establishments ||= v.map{ |e,ev| Establishment.new(zom_conn, @city_id, ev) } # elsif k == 'cuisines' the returned cuisines here are just a string.. else #puts "ATTR @#{k} val #{v}" self.instance_variable_set("@#{k}", v) end end self end
to_s()
click to toggle source
Calls superclass method
Zomato2::EntityBase#to_s
# File lib/zomato2/restaurant.rb, line 35 def to_s; super; end