Class: Hungrytable::RestaurantSearch
- Inherits:
-
Object
- Object
- Hungrytable::RestaurantSearch
- Includes:
- RequestExtensions
- Defined in:
- lib/hungrytable/restaurant_search.rb
Overview
Searches for available reservation times at a restaurant
Constant Summary collapse
- ATTRIBUTES =
Attributes that map directly to API response fields
i[ cuisine_type early_security_ID early_time error_ID exact_security_ID exact_time later_security_ID later_time latitude longitude neighborhood_name restaurant_name results_key ].freeze
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#restaurant ⇒ Object
readonly
Returns the value of attribute restaurant.
Instance Method Summary collapse
-
#ideal_security_id ⇒ String?
Get the best available security ID.
-
#ideal_time ⇒ String?
Get the best available time.
-
#initialize(restaurant, opts = {}) ⇒ RestaurantSearch
constructor
A new instance of RestaurantSearch.
-
#party_size ⇒ Integer
Get the party size for this search.
-
#valid? ⇒ Boolean
Check if the search was valid.
Constructor Details
#initialize(restaurant, opts = {}) ⇒ RestaurantSearch
Returns a new instance of RestaurantSearch.
29 30 31 32 33 34 35 36 |
# File 'lib/hungrytable/restaurant_search.rb', line 29 def initialize(restaurant, opts = {}) @opts = opts ensure_required_opts validate_date_time_type validate_party_size @requester = opts[:requester] || GetRequest @restaurant = restaurant end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
27 28 29 |
# File 'lib/hungrytable/restaurant_search.rb', line 27 def opts @opts end |
#restaurant ⇒ Object (readonly)
Returns the value of attribute restaurant.
27 28 29 |
# File 'lib/hungrytable/restaurant_search.rb', line 27 def restaurant @restaurant end |
Instance Method Details
#ideal_security_id ⇒ String?
Get the best available security ID
55 56 57 |
# File 'lib/hungrytable/restaurant_search.rb', line 55 def ideal_security_id exact_security_ID || early_security_ID || later_security_ID end |
#ideal_time ⇒ String?
Get the best available time
61 62 63 |
# File 'lib/hungrytable/restaurant_search.rb', line 61 def ideal_time exact_time || early_time || later_time end |
#party_size ⇒ Integer
Get the party size for this search
67 68 69 |
# File 'lib/hungrytable/restaurant_search.rb', line 67 def party_size opts[:party_size] end |
#valid? ⇒ Boolean
Check if the search was valid
40 41 42 |
# File 'lib/hungrytable/restaurant_search.rb', line 40 def valid? error_ID.to_s == '0' end |