Class: Blat::ListConsumingQueue
- Inherits:
-
ConsumingQueue
- Object
- Queue
- ConsumingQueue
- Blat::ListConsumingQueue
- Defined in:
- lib/blat/queue.rb
Overview
The ListConsumingQueue is similar to the ConsumingQueue except that it takes its argument in the form of an Enumerable object.
Instance Attribute Summary
Attributes inherited from Queue
Instance Method Summary collapse
-
#consume(list, connections = @max_connects) ⇒ Object
Download all of the URLs or Curl::Easy objects in the given list, and optionally execute the given block on completion for each.
Methods inherited from Queue
#active?, #add, #cancel, #idle?, #initialize, #perform, #perform_nonblock, #remove, #request_count, #requests
Constructor Details
This class inherits a constructor from Blat::Queue
Instance Method Details
#consume(list, connections = @max_connects) ⇒ Object
Download all of the URLs or Curl::Easy objects in the given list, and optionally execute the given block on completion for each
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/blat/queue.rb', line 169 def consume(list, connections = @max_connects) item = 0 # Start at item 0 list = list.to_a # Ensure we can address with [] perform do while request_count < connections && new_link = list[item] item += 1 # Add with config block if appropriate if block_given? add(new_link) { |req| yield(req) } else add(new_link) end end end end |