Class: ProgressBar::Bar
- Inherits:
-
Meter
- Object
- Meter
- ProgressBar::Bar
- Defined in:
- lib/progress_bar/meters/bar.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #bar_width ⇒ Object
-
#initialize(count, max, width) ⇒ Bar
constructor
A new instance of Bar.
- #progress_width ⇒ Object
- #remaining_width ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(count, max, width) ⇒ Bar
Returns a new instance of Bar.
7 8 9 |
# File 'lib/progress_bar/meters/bar.rb', line 7 def initialize(count, max, width) @count, @max, @width = count, max, width end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
5 6 7 |
# File 'lib/progress_bar/meters/bar.rb', line 5 def count @count end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
5 6 7 |
# File 'lib/progress_bar/meters/bar.rb', line 5 def max @max end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/progress_bar/meters/bar.rb', line 5 def width @width end |
Instance Method Details
#bar_width ⇒ Object
18 19 20 |
# File 'lib/progress_bar/meters/bar.rb', line 18 def width - 2 end |
#progress_width ⇒ Object
22 23 24 |
# File 'lib/progress_bar/meters/bar.rb', line 22 def progress_width ((count.to_f / max) * ).ceil end |
#remaining_width ⇒ Object
26 27 28 |
# File 'lib/progress_bar/meters/bar.rb', line 26 def remaining_width - progress_width end |
#to_s ⇒ Object
11 12 13 14 15 16 |
# File 'lib/progress_bar/meters/bar.rb', line 11 def to_s "[" + "#" * progress_width + " " * remaining_width + "]" end |