Class: Zomato2::Restaurant
- Inherits:
-
EntityBase
- Object
- EntityBase
- Zomato2::Restaurant
- Defined in:
- lib/zomato2/restaurant.rb
Instance Attribute Summary collapse
-
#all_reviews_count ⇒ Object
readonly
Returns the value of attribute all_reviews_count.
-
#average_cost_for_two ⇒ Object
readonly
Returns the value of attribute average_cost_for_two.
-
#city_id ⇒ Object
readonly
Returns the value of attribute city_id.
-
#cuisines ⇒ Object
readonly
Returns the value of attribute cuisines.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#deeplink ⇒ Object
readonly
Returns the value of attribute deeplink.
-
#establishments ⇒ Object
Returns the value of attribute establishments.
-
#events_url ⇒ Object
readonly
Returns the value of attribute events_url.
-
#featured_image ⇒ Object
readonly
Returns the value of attribute featured_image.
-
#has_online_delivery ⇒ Object
readonly
Returns the value of attribute has_online_delivery.
-
#has_table_booking ⇒ Object
readonly
Returns the value of attribute has_table_booking.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_delivering_now ⇒ Object
readonly
Returns the value of attribute is_delivering_now.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#menu_url ⇒ Object
readonly
Returns the value of attribute menu_url.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#phone_numbers ⇒ Object
readonly
Returns the value of attribute phone_numbers.
-
#photo_count ⇒ Object
readonly
Returns the value of attribute photo_count.
-
#photos ⇒ Object
readonly
Returns the value of attribute photos.
-
#photos_url ⇒ Object
readonly
Returns the value of attribute photos_url.
-
#price_range ⇒ Object
readonly
Returns the value of attribute price_range.
-
#reviews ⇒ Object
Returns the value of attribute reviews.
-
#thumb ⇒ Object
readonly
Returns the value of attribute thumb.
-
#user_rating ⇒ Object
readonly
Returns the value of attribute user_rating.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
-
#details(start: nil, count: nil) ⇒ Object
this doesn’t actually give any more detailed info..
-
#initialize(zom_conn, attributes) ⇒ Restaurant
constructor
A new instance of Restaurant.
- #menu(start: nil, count: nil) ⇒ Object
- #to_s ⇒ Object
Methods inherited from EntityBase
Constructor Details
#initialize(zom_conn, attributes) ⇒ Restaurant
Returns a new instance of Restaurant.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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 |
Instance Attribute Details
#all_reviews_count ⇒ Object (readonly)
Returns the value of attribute all_reviews_count.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def all_reviews_count @all_reviews_count end |
#average_cost_for_two ⇒ Object (readonly)
Returns the value of attribute average_cost_for_two.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def average_cost_for_two @average_cost_for_two end |
#city_id ⇒ Object (readonly)
Returns the value of attribute city_id.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def city_id @city_id end |
#cuisines ⇒ Object (readonly)
Returns the value of attribute cuisines.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def cuisines @cuisines end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def currency @currency end |
#deeplink ⇒ Object (readonly)
Returns the value of attribute deeplink.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def deeplink @deeplink end |
#establishments ⇒ Object
Returns the value of attribute establishments.
8 9 10 |
# File 'lib/zomato2/restaurant.rb', line 8 def establishments @establishments end |
#events_url ⇒ Object (readonly)
Returns the value of attribute events_url.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def events_url @events_url end |
#featured_image ⇒ Object (readonly)
Returns the value of attribute featured_image.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def featured_image @featured_image end |
#has_online_delivery ⇒ Object (readonly)
Returns the value of attribute has_online_delivery.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def has_online_delivery @has_online_delivery end |
#has_table_booking ⇒ Object (readonly)
Returns the value of attribute has_table_booking.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def has_table_booking @has_table_booking end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def id @id end |
#is_delivering_now ⇒ Object (readonly)
Returns the value of attribute is_delivering_now.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def is_delivering_now @is_delivering_now end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def location @location end |
#menu_url ⇒ Object (readonly)
Returns the value of attribute menu_url.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def @menu_url end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def name @name end |
#phone_numbers ⇒ Object (readonly)
Returns the value of attribute phone_numbers.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def phone_numbers @phone_numbers end |
#photo_count ⇒ Object (readonly)
Returns the value of attribute photo_count.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def photo_count @photo_count end |
#photos ⇒ Object (readonly)
Returns the value of attribute photos.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def photos @photos end |
#photos_url ⇒ Object (readonly)
Returns the value of attribute photos_url.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def photos_url @photos_url end |
#price_range ⇒ Object (readonly)
Returns the value of attribute price_range.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def price_range @price_range end |
#reviews ⇒ Object
Returns the value of attribute reviews.
8 9 10 |
# File 'lib/zomato2/restaurant.rb', line 8 def reviews @reviews end |
#thumb ⇒ Object (readonly)
Returns the value of attribute thumb.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def thumb @thumb end |
#user_rating ⇒ Object (readonly)
Returns the value of attribute user_rating.
4 5 6 |
# File 'lib/zomato2/restaurant.rb', line 4 def @user_rating end |
Instance Method Details
#<=>(other) ⇒ Object
41 42 43 |
# File 'lib/zomato2/restaurant.rb', line 41 def <=>(other) @id <=> other.id end |
#==(other) ⇒ Object
37 38 39 |
# 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) ⇒ Object
this doesn’t actually give any more detailed info..
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# 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 |
#menu(start: nil, count: nil) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/zomato2/restaurant.rb', line 45 def (start: nil, count: nil) q = {res_id: @id } q[:start] = start if start q[:count] = count if count results = get('dailymenu', q) return nil if results['message'] == "No Daily Menu Available" results['daily_menu'].map { |e| Menu.new(@zom_conn, @id, e['daily_menu']) } end |
#to_s ⇒ Object
35 |
# File 'lib/zomato2/restaurant.rb', line 35 def to_s; super; end |