Class: ProgressBar::Components::Percentage
- Inherits:
-
Object
- Object
- ProgressBar::Components::Percentage
- Defined in:
- lib/ruby-progressbar/components/percentage.rb
Instance Attribute Summary collapse
-
#progress ⇒ Object
Returns the value of attribute progress.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Percentage
constructor
A new instance of Percentage.
- #justified_percentage ⇒ Object
- #justified_percentage_with_precision ⇒ Object
- #percentage ⇒ Object
- #percentage_with_precision ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Percentage
Returns a new instance of Percentage.
6 7 8 |
# File 'lib/ruby-progressbar/components/percentage.rb', line 6 def initialize( = {}) self.progress = [:progress] end |
Instance Attribute Details
#progress ⇒ Object
Returns the value of attribute progress.
4 5 6 |
# File 'lib/ruby-progressbar/components/percentage.rb', line 4 def progress @progress end |
Instance Method Details
#justified_percentage ⇒ Object
14 15 16 |
# File 'lib/ruby-progressbar/components/percentage.rb', line 14 def justified_percentage progress.percentage_completed.to_s.rjust(3) end |
#justified_percentage_with_precision ⇒ Object
22 23 24 |
# File 'lib/ruby-progressbar/components/percentage.rb', line 22 def justified_percentage_with_precision progress.percentage_completed_with_precision.to_s.rjust(6) end |
#percentage ⇒ Object
10 11 12 |
# File 'lib/ruby-progressbar/components/percentage.rb', line 10 def percentage progress.percentage_completed.to_s end |
#percentage_with_precision ⇒ Object
18 19 20 |
# File 'lib/ruby-progressbar/components/percentage.rb', line 18 def percentage_with_precision progress.percentage_completed_with_precision end |