Module: Enumerable

Defined in:
lib/each_with_progress.rb

Instance Method Summary collapse

Instance Method Details

#each_with_progress(&block) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/each_with_progress.rb', line 2

def each_with_progress(&block)
  out = STDERR
  count = self.count
  self.each_with_index do |element,i|
    out.print sprintf("%s", ewp_makeProgress(i + 1,count)) + "\r"
    block.call element
  end
  out.print sprintf("%s","                                               " + "\r")
  self
end