Class: MultiProgressBar::BarRenderer
- Inherits:
-
ProgressBar
- Object
- ProgressBar
- MultiProgressBar::BarRenderer
- Defined in:
- lib/multi_progress_bar/bar_renderer.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary collapse
-
#total ⇒ Object
writeonly
Sets the attribute total.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #do_percentage ⇒ Object
- #fmt_current ⇒ Object
- #fmt_total ⇒ Object
- #get_width ⇒ Object
-
#initialize(title, total, width, &block) ⇒ BarRenderer
constructor
A new instance of BarRenderer.
- #restart ⇒ Object
- #show ⇒ Object
- #title=(new_title) ⇒ Object
Constructor Details
#initialize(title, total, width, &block) ⇒ BarRenderer
Returns a new instance of BarRenderer.
6 7 8 9 10 11 |
# File 'lib/multi_progress_bar/bar_renderer.rb', line 6 def initialize(title, total, width, &block) @block = block @buffer = StringIO.new @width = width super(title, total, @buffer) end |
Instance Attribute Details
#total=(value) ⇒ Object (writeonly)
Sets the attribute total
3 4 5 |
# File 'lib/multi_progress_bar/bar_renderer.rb', line 3 def total=(value) @total = value end |
#width ⇒ Object
Returns the value of attribute width.
4 5 6 |
# File 'lib/multi_progress_bar/bar_renderer.rb', line 4 def width @width end |
Instance Method Details
#do_percentage ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/multi_progress_bar/bar_renderer.rb', line 42 def do_percentage if @current.zero? 0 else super end end |
#fmt_current ⇒ Object
13 14 15 |
# File 'lib/multi_progress_bar/bar_renderer.rb', line 13 def fmt_current @current end |
#fmt_total ⇒ Object
17 18 19 |
# File 'lib/multi_progress_bar/bar_renderer.rb', line 17 def fmt_total @total end |
#get_width ⇒ Object
32 33 34 |
# File 'lib/multi_progress_bar/bar_renderer.rb', line 32 def get_width @width end |
#restart ⇒ Object
36 37 38 39 40 |
# File 'lib/multi_progress_bar/bar_renderer.rb', line 36 def restart set(0) @start_time = Time.now @previous_time = @start_time end |
#show ⇒ Object
21 22 23 24 25 |
# File 'lib/multi_progress_bar/bar_renderer.rb', line 21 def show super @block.call(@buffer.string) @buffer.string = "" end |
#title=(new_title) ⇒ Object
27 28 29 30 |
# File 'lib/multi_progress_bar/bar_renderer.rb', line 27 def title=(new_title) @title = new_title show end |