class Blat::ListConsumingQueue

The ListConsumingQueue is similar to the ConsumingQueue except that it takes its argument in the form of an Enumerable object.

Public Instance Methods

consume(list, connections = @max_connects) { |req| ... } click to toggle source

Download all of the URLs or Curl::Easy objects in the given list, and optionally execute the given block on completion for each

# 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