Module: ProgressBar::WithProgress
- Defined in:
- lib/progress_bar/with_progress.rb
Instance Method Summary collapse
- #each_with_progress(*args, &block) ⇒ Object (also: #with_progress)
Instance Method Details
#each_with_progress(*args, &block) ⇒ Object Also known as: with_progress
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/progress_bar/with_progress.rb', line 5 def each_with_progress(*args, &block) = ProgressBar.new(count, *args) if block each{ |obj| yield(obj).tap{ .increment! } } else Enumerator.new{ |yielder| each do |obj| (yielder << obj).tap{ .increment! } end } end end |