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

Instance Method Details

#pauseObject



17
18
19
# File 'lib/progress_bar/components/timer.rb', line 17

def pause
  stop
end

#resetObject



33
34
35
36
# File 'lib/progress_bar/components/timer.rb', line 33

def reset
  @started_at = nil
  @stopped_at = nil
end

#resumeObject



21
22
23
# File 'lib/progress_bar/components/timer.rb', line 21

def resume
  start
end

#startObject



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

Returns:

  • (Boolean)


25
26
27
# File 'lib/progress_bar/components/timer.rb', line 25

def started?
  !!@started_at
end

#stopObject



13
14
15
# File 'lib/progress_bar/components/timer.rb', line 13

def stop
  @stopped_at = now
end

#stopped?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/progress_bar/components/timer.rb', line 29

def stopped?
  !!@stopped_at
end