Class: Sprout::ProgressBarManager

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
sprout/lib/sprout/progress_bar.rb

Instance Method Summary (collapse)

Constructor Details

- (ProgressBarManager) initialize

A new instance of ProgressBarManager



299
300
301
302
303
# File 'sprout/lib/sprout/progress_bar.rb', line 299

def initialize
  @finished = {}
  @bars = {}
  @outs = {}
end

Instance Method Details

- (Object) add(title, total1)



305
306
307
308
309
310
311
# File 'sprout/lib/sprout/progress_bar.rb', line 305

def add(title, total1)
  #    if(@bars[title])
  #      raise StandardError.new
  #    end
  @outs[title] = ProgressBarOutputStream.new(self)
  @bars[title] = ProgressBarImpl.new(title, total1, @outs[title])
end

- (Object) flush



325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'sprout/lib/sprout/progress_bar.rb', line 325

def flush
  @bars.keys.each do |title|
    print(title)
  end
  
  @bars.values.each do |bar|
    if(bar.finished?)
      print(bar.title)
      outio.print "\n"
      @outs.delete(bar.title)
      @bars.delete(bar.title)
    end
  end
end

- (Object) outio



321
322
323
# File 'sprout/lib/sprout/progress_bar.rb', line 321

def outio
  ProgressBar.outio
end


313
314
315
316
317
318
319
# File 'sprout/lib/sprout/progress_bar.rb', line 313

def print(title)
  str = ''
  str += @outs[title].to_s
  str += "\r"
  outio.print "\r"
  outio.print str
end