Class: Hungrytable::Restaurant

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

Overview

Represents a restaurant and its details from the OpenTable API

Constant Summary collapse

ATTRIBUTES =

Attributes that map directly to API response fields

%i[
  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
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Restaurant.



34
35
36
37
# File 'lib/hungrytable/restaurant.rb', line 34

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

Instance Attribute Details

#restaurant_idObject (readonly)

Returns the value of attribute restaurant_id.



32
33
34
# File 'lib/hungrytable/restaurant.rb', line 32

def restaurant_id
  @restaurant_id
end

Instance Method Details

#idObject

Alias for consistency



40
41
42
# File 'lib/hungrytable/restaurant.rb', line 40

def id
  @restaurant_id
end

#valid?Boolean

Check if the restaurant query was valid

Returns:

  • (Boolean)

    true if no errors



46
47
48
# File 'lib/hungrytable/restaurant.rb', line 46

def valid?
  error_ID.to_s == '0'
end