Class: ProgressBar::Percentage
- Inherits:
-
Meter
- Object
- Meter
- ProgressBar::Percentage
- Defined in:
- lib/progress_bar/meters/percentage.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) ⇒ Percentage
constructor
A new instance of Percentage.
- #to_s ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(count, max) ⇒ Percentage
Returns a new instance of Percentage.
7 8 9 |
# File 'lib/progress_bar/meters/percentage.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/percentage.rb', line 5 def count @count end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
5 6 7 |
# File 'lib/progress_bar/meters/percentage.rb', line 5 def max @max end |
Instance Method Details
#to_s ⇒ Object
11 12 13 |
# File 'lib/progress_bar/meters/percentage.rb', line 11 def to_s "[%6.2f%%]" % (count.to_f / max * 100) end |
#width ⇒ Object
15 16 17 |
# File 'lib/progress_bar/meters/percentage.rb', line 15 def width 9 end |