Class: WebCrawler::Handler
- Inherits:
-
Object
- Object
- WebCrawler::Handler
- Defined in:
- lib/web_crawler/handler.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(*responses_or_request, &handler) ⇒ Handler
constructor
A new instance of Handler.
- #process ⇒ Object
Constructor Details
#initialize(*responses_or_request, &handler) ⇒ Handler
Returns a new instance of Handler.
5 6 7 8 9 10 11 12 |
# File 'lib/web_crawler/handler.rb', line 5 def initialize(*responses_or_request, &handler) @handler = handler if responses_or_request.first.is_a?(BatchRequest) @target = responses_or_request.first else @target = responses_or_request.flatten end end |
Instance Method Details
#process ⇒ Object
14 15 16 17 18 |
# File 'lib/web_crawler/handler.rb', line 14 def process @result ||= @target.map do |response| @handler.call(response, @target) end end |