Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/cem/ccommon.rb

Instance Method Summary collapse

Instance Method Details

#with_progress(&block) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/cem/ccommon.rb', line 85

def with_progress(&block)

   crequire 'progress_bar'

	bar = ProgressBar.new(count)
	if block
		each{|obj| yield(obj).tap{bar.increment!}}
	else
		Enumerator.new{ |yielder|
			self.each do |obj|
				(yielder << obj).tap{bar.increment!}
			end
		}
	end
end