Module: TableUtils::Progress
- Defined in:
- lib/table_utils/progress.rb
Constant Summary collapse
- DefaultOptions =
{ format: "%a |%b %c/%C =>%i| %E", throttle_rate: 0.1, }
Class Method Summary collapse
Class Method Details
.bar(options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/table_utils/progress.rb', line 10 def self. = {} = ProgressBar.create DefaultOptions.merge .format("%a: |%i| %c") if .total == nil if block_given? begin yield ensure if .total .finish unless .finished? end end else end end |
.over(enum, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/table_utils/progress.rb', line 26 def self.over enum, = {} = .dup unless .include? :total [:total] = enum.count end Progress. do || enum.each do |i| .increment yield i, end end end |