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
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/progress_bar/with_progress.rb', line 3 def each_with_progress(*args, &block) = ProgressBar.new(count, *args) if block each{|obj| yield(obj).tap{.increment!}} else Enumerator.new{|yielder| self.each do |obj| (yielder << obj).tap{.increment!} end } end end |