Class: ParallelRequestScraper
- Inherits:
-
Object
- Object
- ParallelRequestScraper
- Defined in:
- lib/trackit_scraper/2003.10.1/lib/parallel_request_scraper.rb
Instance Method Summary collapse
-
#initialize(navigator, login_command, threads) ⇒ ParallelRequestScraper
constructor
A new instance of ParallelRequestScraper.
- #scrape(request_ids, &block) ⇒ Object
Constructor Details
#initialize(navigator, login_command, threads) ⇒ ParallelRequestScraper
Returns a new instance of ParallelRequestScraper.
7 8 9 10 11 |
# File 'lib/trackit_scraper/2003.10.1/lib/parallel_request_scraper.rb', line 7 def initialize(navigator, login_command, threads) @navigator = navigator @login_command = login_command @threads = threads end |
Instance Method Details
#scrape(request_ids, &block) ⇒ Object
13 14 15 16 17 |
# File 'lib/trackit_scraper/2003.10.1/lib/parallel_request_scraper.rb', line 13 def scrape(request_ids, &block) @request_ids = request_ids.clone @semaphore = Mutex.new @threads.times.map { Thread.new { scrape_requests &block } }.each { |t| t.join } end |