class Formatador::ProgressBar
def complete?
def complete? current == total end
def increment(increment = 1)
def increment(increment = 1) @lock.synchronize do return if complete? @current += increment.to_i @complete_proc.call(self) if complete? Formatador.redisplay_progressbar(current, total, opts) end end
def initialize(total, opts = {}, &block)
def initialize(total, opts = {}, &block) @current = opts.delete(:start) || 0 @total = total.to_i @opts = opts @lock = Mutex.new @complete_proc = block_given? ? block : Proc.new { } end