module TableUtils::Progress
Constants
- DefaultOptions
Public Class Methods
bar(options = {}) { |bar| ... }
click to toggle source
# File lib/table_utils/progress.rb, line 10 def self.bar options = {} bar = ProgressBar.create DefaultOptions.merge options bar.format("%a: |%i| %c") if bar.total == nil if block_given? begin yield bar ensure if bar.total bar.finish unless bar.finished? end end else bar end end
over(enum, options = {}) { |i, bar| ... }
click to toggle source
# File lib/table_utils/progress.rb, line 26 def self.over enum, options = {} options = options.dup unless options.include? :total options[:total] = enum.count end Progress.bar options do |bar| enum.each do |i| bar.increment yield i, bar end end end