Class: Hungrytable::Restaurant

Inherits:
Object
  • Object
show all
Includes:
RequestExtensions
Defined in:
lib/hungrytable/restaurant.rb

Instance Method Summary collapse

Constructor Details

#initialize(restaurant_id, opts = {}) ⇒ Restaurant

Returns a new instance of Restaurant.



5
6
7
8
# File 'lib/hungrytable/restaurant.rb', line 5

def initialize restaurant_id, opts={}
  @requester     = opts[:requester] || GetRequest
  @restaurant_id = restaurant_id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/hungrytable/restaurant.rb', line 18

def method_missing meth, *args, &blk
  if %w(
        address
        city
        error_ID
        error_message
        image_link
        latitude
        longitude
        metro_name
        neighborhood_name
        parking
        parking_details
        phone
        postal_code
        price_range
        primary_food_type
        restaurant_description
        restaurant_ID
        restaurant_name
        state
        url
      ).map(&:to_sym).include?(meth)
    return details["ns:#{meth.to_s.camelize.gsub("Id","ID")}"]
  end
  super
end

Instance Method Details

#idObject



10
11
12
# File 'lib/hungrytable/restaurant.rb', line 10

def id
  @restaurant_id
end

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/hungrytable/restaurant.rb', line 14

def valid?
  error_ID == "0"
end