Module: ProgressBar::Components::Timer
- Included in:
- ElapsedTimer, EstimatedTimer, Rate, Throttle
- Defined in:
- lib/ruby-progressbar/components/timer.rb
Constant Summary collapse
- TIME_FORMAT =
'%02d:%02d:%02d'
Instance Method Summary collapse
- #pause ⇒ Object
- #reset ⇒ Object
- #resume ⇒ Object
- #start ⇒ Object
- #started? ⇒ Boolean
- #stop ⇒ Object
- #stopped? ⇒ Boolean
Instance Method Details
#pause ⇒ Object
19 20 21 |
# File 'lib/ruby-progressbar/components/timer.rb', line 19 def pause stop end |
#reset ⇒ Object
35 36 37 38 |
# File 'lib/ruby-progressbar/components/timer.rb', line 35 def reset @started_at = nil @stopped_at = nil end |
#resume ⇒ Object
23 24 25 |
# File 'lib/ruby-progressbar/components/timer.rb', line 23 def resume start end |
#start ⇒ Object
8 9 10 11 |
# File 'lib/ruby-progressbar/components/timer.rb', line 8 def start @started_at = stopped? ? now - (@stopped_at - @started_at) : now @stopped_at = nil end |
#started? ⇒ Boolean
27 28 29 |
# File 'lib/ruby-progressbar/components/timer.rb', line 27 def started? !!@started_at end |
#stop ⇒ Object
13 14 15 16 17 |
# File 'lib/ruby-progressbar/components/timer.rb', line 13 def stop return unless started? @stopped_at = now end |
#stopped? ⇒ Boolean
31 32 33 |
# File 'lib/ruby-progressbar/components/timer.rb', line 31 def stopped? !!@stopped_at end |