Sha256: 63d764b51cb25397057dd182c0850c89d2dc3f7ace6528efc78f41b961be227d

Contents?: true

Size: 699 Bytes

Versions: 5

Compression:

Stored size: 699 Bytes

Contents

module Enumerable
  # note that Progress.step is called automatically
  # ==== Example
  #   [1, 2, 3].each_with_progress('Numbers') do |number|
  #     sleep(number)
  #   end
  def each_with_progress(name)
    Progress.start(name, length) do
      each do |item|
        yield item
        Progress.step
      end
    end
  end

  # note that Progress.step is called automatically
  # ==== Example
  #   [1, 2, 3].each_with_index_and_progress('Numbers') do |number, index|
  #     sleep(number)
  #   end
  def each_with_index_and_progress(name)
    Progress.start(name, length) do
      each_with_index do |item, index|
        yield item, index
        Progress.step
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
progress-0.0.7.1 lib/progress/enumerable.rb
progress-0.0.4 lib/progress/enumerable.rb
progress-0.0.7 lib/progress/enumerable.rb
progress-0.0.3 lib/progress/enumerable.rb
progress-0.0.5 lib/progress/enumerable.rb