Class: ProgressBar::Components::Rate
- Inherits:
-
Object
- Object
- ProgressBar::Components::Rate
- Defined in:
- lib/ruby-progressbar/components/rate.rb
Instance Attribute Summary collapse
-
#progress ⇒ Object
Returns the value of attribute progress.
-
#rate_scale ⇒ Object
Returns the value of attribute rate_scale.
-
#timer ⇒ Object
Returns the value of attribute timer.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Rate
constructor
A new instance of Rate.
- #rate_of_change(format_string = '%i') ⇒ Object
- #rate_of_change_with_precision ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Rate
Returns a new instance of Rate.
8 9 10 11 12 |
# File 'lib/ruby-progressbar/components/rate.rb', line 8 def initialize( = {}) self.rate_scale = [:rate_scale] || lambda { |x| x } self.timer = [:timer] self.progress = [:progress] end |
Instance Attribute Details
#progress ⇒ Object
Returns the value of attribute progress.
4 5 6 |
# File 'lib/ruby-progressbar/components/rate.rb', line 4 def progress @progress end |
#rate_scale ⇒ Object
Returns the value of attribute rate_scale.
4 5 6 |
# File 'lib/ruby-progressbar/components/rate.rb', line 4 def rate_scale @rate_scale end |
#timer ⇒ Object
Returns the value of attribute timer.
4 5 6 |
# File 'lib/ruby-progressbar/components/rate.rb', line 4 def timer @timer end |
Instance Method Details
#rate_of_change(format_string = '%i') ⇒ Object
14 15 16 17 18 |
# File 'lib/ruby-progressbar/components/rate.rb', line 14 def rate_of_change(format_string = '%i') return '0' if elapsed_seconds <= 0 format_string % scaled_rate end |
#rate_of_change_with_precision ⇒ Object
20 21 22 |
# File 'lib/ruby-progressbar/components/rate.rb', line 20 def rate_of_change_with_precision rate_of_change('%.2f') end |