class Timers::Interval
A collection of timers which may fire at different times
Public Class Methods
new()
click to toggle source
Get the current elapsed monotonic time.
# File lib/timers/interval.rb, line 12 def initialize @total = 0.0 @current = nil end
Public Instance Methods
start()
click to toggle source
# File lib/timers/interval.rb, line 17 def start return if @current @current = now end
stop()
click to toggle source
# File lib/timers/interval.rb, line 23 def stop return unless @current @total += duration @current = nil end
to_f()
click to toggle source
# File lib/timers/interval.rb, line 31 def to_f @total + duration end
Protected Instance Methods
duration()
click to toggle source
# File lib/timers/interval.rb, line 35 def duration now - @current end
now()
click to toggle source
# File lib/timers/interval.rb, line 39 def now ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) end