Class: CoffeeOutside::Location
- Inherits:
-
Object
- Object
- CoffeeOutside::Location
- Defined in:
- lib/coffeeoutside/locations.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#location_hint ⇒ Object
readonly
Returns the value of attribute location_hint.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nearby_coffee ⇒ Object
readonly
Returns the value of attribute nearby_coffee.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(params) ⇒ Location
constructor
A new instance of Location.
- #paused? ⇒ Boolean
- #to_s ⇒ Object
- #weather_appropriate?(forecast) ⇒ Boolean
Constructor Details
#initialize(params) ⇒ Location
Returns a new instance of Location.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/coffeeoutside/locations.rb', line 9 def initialize(params) if params["name"] @name = params["name"] else raise "Location class requires name key" end @paused = params["paused"] || false @nearby_coffee = params["nearby_coffee"] || [] @url = params["url"] if params["url"] @address = params["address"] if params["address"] @location_hint = params["location_hint"] if params["location_hint"] # Forecast related @rainy_day = params["rainy_day"] || false @high_limit = params["high_limit"] if params["high_limit"] @low_limit = params["low_limit"] if params["low_limit"] # Save params for any dispatcher-specific values @params = params end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
7 8 9 |
# File 'lib/coffeeoutside/locations.rb', line 7 def address @address end |
#location_hint ⇒ Object (readonly)
Returns the value of attribute location_hint.
7 8 9 |
# File 'lib/coffeeoutside/locations.rb', line 7 def location_hint @location_hint end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/coffeeoutside/locations.rb', line 7 def name @name end |
#nearby_coffee ⇒ Object (readonly)
Returns the value of attribute nearby_coffee.
7 8 9 |
# File 'lib/coffeeoutside/locations.rb', line 7 def nearby_coffee @nearby_coffee end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/coffeeoutside/locations.rb', line 7 def url @url end |
Instance Method Details
#paused? ⇒ Boolean
30 31 32 |
# File 'lib/coffeeoutside/locations.rb', line 30 def paused? @paused end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/coffeeoutside/locations.rb', line 44 def to_s @name end |
#weather_appropriate?(forecast) ⇒ Boolean
34 35 36 37 38 39 40 41 42 |
# File 'lib/coffeeoutside/locations.rb', line 34 def weather_appropriate?(forecast) # TODO: stderr reasons? return false if (forecast.rainy? && !@rainy_day) || (@low_limit && (forecast.temperature < @low_limit)) || (@high_limit && (forecast.temperature > @high_limit)) true end |