Module: ProgressBar::Components::Timer
- Included in:
- ElapsedTimer, EstimatedTimer
- Defined in:
- lib/progress_bar/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
17 18 19 |
# File 'lib/progress_bar/components/timer.rb', line 17 def pause stop end |
#reset ⇒ Object
33 34 35 36 |
# File 'lib/progress_bar/components/timer.rb', line 33 def reset @started_at = nil @stopped_at = nil end |
#resume ⇒ Object
21 22 23 |
# File 'lib/progress_bar/components/timer.rb', line 21 def resume start end |
#start ⇒ Object
8 9 10 11 |
# File 'lib/progress_bar/components/timer.rb', line 8 def start @started_at = stopped? ? now - (@stopped_at - @started_at) : now @stopped_at = nil end |
#started? ⇒ Boolean
25 26 27 |
# File 'lib/progress_bar/components/timer.rb', line 25 def started? !!@started_at end |
#stop ⇒ Object
13 14 15 |
# File 'lib/progress_bar/components/timer.rb', line 13 def stop @stopped_at = now end |
#stopped? ⇒ Boolean
29 30 31 |
# File 'lib/progress_bar/components/timer.rb', line 29 def stopped? !!@stopped_at end |