class Monotonic::Time

Attributes

seconds_since_boot[R]

Public Class Methods

new() click to toggle source
# File lib/Monotonic/Time.rb, line 19
def initialize
  @boot_time = Sys::Uptime.boot_time
  @seconds_since_boot = Process.clock_gettime(Process::CLOCK_MONOTONIC)
end
now() click to toggle source
# File lib/Monotonic/Time.rb, line 11
def now
  self.new
end

Public Instance Methods

+(monotonic_time_addend) click to toggle source
# File lib/Monotonic/Time.rb, line 24
def +(monotonic_time_addend)
  @seconds_since_boot + monotonic_time_addend.seconds_since_boot
end
-(monotonic_time_subtrahend) click to toggle source
# File lib/Monotonic/Time.rb, line 28
def -(monotonic_time_subtrahend)
  @seconds_since_boot - monotonic_time_subtrahend.seconds_since_boot
end
to_s() click to toggle source
# File lib/Monotonic/Time.rb, line 32
def to_s
  "#{@seconds_since_boot} seconds since boot."
end
to_time() click to toggle source
# File lib/Monotonic/Time.rb, line 36
def to_time
  @boot_time + @seconds_since_boot
end