Sha256: 0fee1e171ed3aea9d7fad844fffb9de01ca8ce7da2b7685d121e7f1c08ef7889
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
require 'enumerator' require 'progress/with_progress' 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 = nil) 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 = nil, &block) with_progress(title).each(&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 = nil, &block) with_progress(title).each_with_index(&block) end end
Version data entries
5 entries across 5 versions & 1 rubygems