class ProgressBar::Timer
Attributes
Public Class Methods
Source
# File lib/ruby-progressbar/timer.rb, line 8 def initialize(options = {}) self.time = options[:time] || ::ProgressBar::Time.new end
Public Instance Methods
Source
# File lib/ruby-progressbar/timer.rb, line 67 def divide_seconds(seconds) hours, seconds = seconds.divmod(3600) minutes, seconds = seconds.divmod(60) [hours, minutes, seconds] end
Source
# File lib/ruby-progressbar/timer.rb, line 57 def elapsed_seconds return 0 unless started? ((stopped_at || time.now) - started_at) end
Source
# File lib/ruby-progressbar/timer.rb, line 63 def elapsed_whole_seconds elapsed_seconds.floor end
Source
# File lib/ruby-progressbar/timer.rb, line 43 def reset self.started_at = nil self.stopped_at = nil end
Source
# File lib/ruby-progressbar/timer.rb, line 12 def start self.started_at = stopped? ? time.now - (stopped_at - started_at) : time.now self.stopped_at = nil end
Source
# File lib/ruby-progressbar/timer.rb, line 17 def stop return unless started? self.stopped_at = time.now end