Class: Turbovax::DataFetcher
- Inherits:
-
Object
- Object
- Turbovax::DataFetcher
- Defined in:
- lib/turbovax/data_fetcher.rb
Overview
This class, given a portal and a twitter handler:
1) executes request for data
2) passes structured appointment data to twitter handler
3) returns appointment data
Instance Method Summary collapse
-
#execute! ⇒ Array<Turbovax::Location>
List of locations and appointments.
-
#initialize(portal, twitter_handler: nil, date: nil, extra_params: {}) ⇒ DataFetcher
constructor
A new instance of DataFetcher.
Constructor Details
#initialize(portal, twitter_handler: nil, date: nil, extra_params: {}) ⇒ DataFetcher
Returns a new instance of DataFetcher.
16 17 18 19 20 21 |
# File 'lib/turbovax/data_fetcher.rb', line 16 def initialize(portal, twitter_handler: nil, date: nil, extra_params: {}) portal.data_fetcher_params = { date: date || DateTime.now }.merge(extra_params) @portal = portal @conn = create_request_connection @twitter_handler = twitter_handler end |
Instance Method Details
#execute! ⇒ Array<Turbovax::Location>
Returns List of locations and appointments.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/turbovax/data_fetcher.rb', line 24 def execute! response = make_request log("make request [DONE]") locations = @portal.parse_response_with_portal(response.body) log("parse response [DONE]") send_to_twitter_handler(locations) locations end |