Sha256: 60dd285b46420bc0bf23cff73568e24fa0fea574515ff7cfd91bde23196fb571

Contents?: true

Size: 763 Bytes

Versions: 10

Compression:

Stored size: 763 Bytes

Contents

require 'enumerator'
require 'progress/with_progress'

# Add with_progress method to Enumerable
module Enumerable
  # run any Enumerable method with progress
  # methods which don't necessarily go through all items (like find, any? or
  # all?) will not show 100%
  # ==== Example
  #   [1, 2, 3].with_progress('Numbers').each do |number|
  #     # code
  #   end
  #
  #   [1, 2, 3].with_progress('Numbers').each_cons(2) do |numbers|
  #     # code
  #   end
  #
  #   (0...100).with_progress('Numbers').select do |numbers|
  #     # code
  #   end
  #
  #   (0...100).with_progress('Numbers').all? do |numbers|
  #     # code
  #   end
  def with_progress(title = nil, length = nil, &block)
    Progress::WithProgress.new(self, title, length, &block)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
progress-3.5.0 lib/progress/enumerable.rb
progress-3.4.0 lib/progress/enumerable.rb
progress-3.3.2 lib/progress/enumerable.rb
progress-3.3.1 lib/progress/enumerable.rb
progress-3.3.0 lib/progress/enumerable.rb
progress-3.2.2 lib/progress/enumerable.rb
progress-3.2.1 lib/progress/enumerable.rb
progress-3.2.0 lib/progress/enumerable.rb
progress-3.1.1 lib/progress/enumerable.rb
progress-3.1.0 lib/progress/enumerable.rb