Class: Turbovax::Handlers::LocationHandler
- Inherits:
-
Object
- Object
- Turbovax::Handlers::LocationHandler
- Defined in:
- lib/turbovax/handlers/location_handler.rb
Overview
Given a list of locations, tweet appointment info for each location
Instance Method Summary collapse
-
#appointment_time_format ⇒ Object
Format of each individual appointment time.
-
#daily_appointment_limit ⇒ Object
Max number of appointment times included per day.
-
#date_format ⇒ Object
Format of each individual date.
-
#day_limit ⇒ Object
Max number of days included in a tweet.
- #execute! ⇒ Object
-
#initialize(locations) ⇒ LocationHandler
constructor
A new instance of LocationHandler.
-
#max_location_limit ⇒ Object
Max locations to tweet at a given time.
-
#should_tweet_for_location(location) ⇒ Boolean
Override this method to to add caching logic.
Constructor Details
#initialize(locations) ⇒ LocationHandler
Returns a new instance of LocationHandler.
9 10 11 |
# File 'lib/turbovax/handlers/location_handler.rb', line 9 def initialize(locations) @locations = locations end |
Instance Method Details
#appointment_time_format ⇒ Object
Format of each individual appointment time. See APIdoc for format apidock.com/ruby/DateTime/strftime
49 50 51 |
# File 'lib/turbovax/handlers/location_handler.rb', line 49 def appointment_time_format "%-l:%M%p" end |
#daily_appointment_limit ⇒ Object
Max number of appointment times included per day
33 34 35 |
# File 'lib/turbovax/handlers/location_handler.rb', line 33 def daily_appointment_limit 3 end |
#date_format ⇒ Object
Format of each individual date. See APIdoc for format apidock.com/ruby/DateTime/strftime
41 42 43 |
# File 'lib/turbovax/handlers/location_handler.rb', line 41 def date_format "%b %-e" end |
#day_limit ⇒ Object
Max number of days included in a tweet
28 29 30 |
# File 'lib/turbovax/handlers/location_handler.rb', line 28 def day_limit 3 end |
#execute! ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/turbovax/handlers/location_handler.rb', line 13 def execute! count = 0 @locations.each do |location| next if count >= max_location_limit count += 1 if handle_location(location) end end |
#max_location_limit ⇒ Object
Max locations to tweet at a given time
23 24 25 |
# File 'lib/turbovax/handlers/location_handler.rb', line 23 def max_location_limit 2 end |
#should_tweet_for_location(location) ⇒ Boolean
Override this method to to add caching logic
55 56 57 |
# File 'lib/turbovax/handlers/location_handler.rb', line 55 def should_tweet_for_location(location) location.available end |