Sha256: fd326a509c8ea5ba2d3716058c4fe79b3bbb66f70ef61e4fe38de910b9ef6281

Contents?: true

Size: 1.01 KB

Versions: 16

Compression:

Stored size: 1.01 KB

Contents

require 'enumerator'
module Enumerable
  # executes any Enumerable method with progress
  # note that methods which don't necessarily go through all items (like find or any?) will not show 100%
  # ==== Example
  #   [1, 2, 3].with_progress('Numbers').each do |number|
  #     sleep(number)
  #   end
  #   [1, 2, 3].with_progress('Numbers').each_cons(2) do |numbers|
  #     p numbers
  #   end
  def with_progress(title)
    Progress::WithProgress.new(self, title)
  end

  # note that Progress.step is called automatically
  # ==== Example
  #   [1, 2, 3].each_with_progress('Numbers') do |number|
  #     sleep(number)
  #   end
  def each_with_progress(title, *args, &block)
    with_progress(title).each(*args, &block)
  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(title, *args, &block)
    with_progress(title).each_with_index(*args, &block)
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
progress-0.2.2 lib/progress/enumerable.rb
progress-0.2.1 lib/progress/enumerable.rb
progress-0.2.0 lib/progress/enumerable.rb
progress-0.1.2 lib/progress/enumerable.rb
progress-0.1.1.3 lib/progress/enumerable.rb
progress-0.1.1.2 lib/progress/enumerable.rb
progress-0.1.1.1 lib/progress/enumerable.rb
progress-0.1.1.0 lib/progress/enumerable.rb
progress-0.1.0.3 lib/progress/enumerable.rb
progress-0.1.0.0 lib/progress/enumerable.rb
progress-0.1.0.1 lib/progress/enumerable.rb
progress-0.1.0.2 lib/progress/enumerable.rb
progress-0.0.9.3 lib/progress/enumerable.rb
progress-0.0.9.0 lib/progress/enumerable.rb
progress-0.0.9.1 lib/progress/enumerable.rb
progress-0.0.9.2 lib/progress/enumerable.rb