Class: MultiProgressBar::TotalBar
- Inherits:
-
Bar
- Object
- ProgressBar
- BarRenderer
- Bar
- MultiProgressBar::TotalBar
- Defined in:
- lib/multi_progress_bar/total_bar.rb
Overview
Works just like Bar
, but displays the total of other bars. TotalBar#inc and TotalBar#set don’t work.
Instance Attribute Summary
Attributes inherited from Bar
Attributes inherited from BarRenderer
Instance Method Summary collapse
-
#initialize(title, bars = MultiProgressBar.bars.dup) ⇒ TotalBar
constructor
Create a new TotalBar.
Methods inherited from Bar
Methods inherited from BarRenderer
#do_percentage, #fmt_current, #fmt_total, #get_width, #restart, #show, #title=
Constructor Details
#initialize(title, bars = MultiProgressBar.bars.dup) ⇒ TotalBar
Create a new TotalBar. bars
is an array of Bar objects, and defaults to all existing bars.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/multi_progress_bar/total_bar.rb', line 7 def initialize(title, = MultiProgressBar..dup) @bars = @bars.each do || .observe do update_total end end total_total = @bars.inject(0) { |sum, | sum + .total } super title, total_total end |