def iterate(collection, progress = 1, &block)
      update(total: collection.count * progress) unless total
      progress_enum = Enumerator.new do |iter|
        collection.each do |elem|
          advance(progress)
          iter.yield(elem)
        end
      end
      block_given? ? progress_enum.each(&block) : progress_enum
    end
def iterate(collection, progress = 1, &block)
      update(total: collection.count * progress) unless total
      progress_enum = Enumerator.new do |iter|
        collection.each do |elem|
          advance(progress)
          iter.yield(elem)
        end
      end
      block_given? ? progress_enum.each(&block) : progress_enum
    end
Iterate over collection either yielding computation to block
 or provided Enumerator. If the bar's `total` was not set,
 it would be taken from `collection.count`, otherwise previously
 set `total` would be used. This allows using the progressbar
 with infinite, lazy, or slowly-calculated enumerators.

 @note
   If `total` is set, iteration will NOT stop after this number of
   iterations, only when provided Enumerable is finished. It may
   be convenient in "unsure number of iterations" situations
   (like downloading in chunks, when server may eventually send
   more chunks than predicted), but be careful to not pass infinite
   enumerators without previosly doing `.take(some_finite_number)`
   on them.

 @example
   bar.iterate(30.times) { ... }

 @param [Enumerable] collection
   the collection to iterate over

 @param [Integer] progress
   the amount to move progress bar by

 @return [Enumerator]

 @api public