Class: ProgressBar::Counter
- Inherits:
-
Meter
- Object
- Meter
- ProgressBar::Counter
- Defined in:
- lib/progress_bar/meters/counter.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
Instance Method Summary collapse
-
#initialize(count, max) ⇒ Counter
constructor
A new instance of Counter.
- #max_counter_width ⇒ Object
- #to_s ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(count, max) ⇒ Counter
Returns a new instance of Counter.
7 8 9 |
# File 'lib/progress_bar/meters/counter.rb', line 7 def initialize(count, max) @count, @max = count, max end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
5 6 7 |
# File 'lib/progress_bar/meters/counter.rb', line 5 def count @count end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
5 6 7 |
# File 'lib/progress_bar/meters/counter.rb', line 5 def max @max end |
Instance Method Details
#max_counter_width ⇒ Object
19 20 21 |
# File 'lib/progress_bar/meters/counter.rb', line 19 def max_counter_width max.to_s.length end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/progress_bar/meters/counter.rb', line 11 def to_s "[%#{max_counter_width}i/%i]" % [count, max] end |
#width ⇒ Object
15 16 17 |
# File 'lib/progress_bar/meters/counter.rb', line 15 def width max.to_s.length * 2 + 3 end |