Class: ProgressBar::Throttle
- Inherits:
-
Object
- Object
- ProgressBar::Throttle
- Defined in:
- lib/ruby-progressbar/throttle.rb
Instance Attribute Summary collapse
-
#rate ⇒ Object
Returns the value of attribute rate.
-
#started_at ⇒ Object
Returns the value of attribute started_at.
-
#stopped_at ⇒ Object
Returns the value of attribute stopped_at.
-
#timer ⇒ Object
Returns the value of attribute timer.
Instance Method Summary collapse
- #choke(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Throttle
constructor
A new instance of Throttle.
Constructor Details
Instance Attribute Details
#rate ⇒ Object
Returns the value of attribute rate.
3 4 5 |
# File 'lib/ruby-progressbar/throttle.rb', line 3 def rate @rate end |
#started_at ⇒ Object
Returns the value of attribute started_at.
3 4 5 |
# File 'lib/ruby-progressbar/throttle.rb', line 3 def started_at @started_at end |
#stopped_at ⇒ Object
Returns the value of attribute stopped_at.
3 4 5 |
# File 'lib/ruby-progressbar/throttle.rb', line 3 def stopped_at @stopped_at end |
#timer ⇒ Object
Returns the value of attribute timer.
3 4 5 |
# File 'lib/ruby-progressbar/throttle.rb', line 3 def timer @timer end |
Instance Method Details
#choke(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/ruby-progressbar/throttle.rb', line 15 def choke( = {}) return unless !timer.started? || .fetch(:force_update_if, false) || timer.elapsed_seconds >= rate timer.restart yield end |