Sha256: 854bb0842dc878ed7117cfe9b54ae35c61460bac850e83bbb971e9de2f48aff5
Contents?: true
Size: 676 Bytes
Versions: 11
Compression:
Stored size: 676 Bytes
Contents
module Skylight module Util class Clock MICROSEC_PER_SEC = 1.to_f / 1_000_000 # Resolution is in seconds def initialize(resolution) @resolution = resolution @usec_mult = MICROSEC_PER_SEC / resolution end def now at(Time.now) end def at(time) sec = time.to_i / @resolution usec = time.usec * @usec_mult (sec + usec).floor end def convert(secs) (secs / @resolution).floor end def to_seconds(clock_val) (clock_val * @resolution).floor end end @clock = Clock.new(0.0001) def self.clock @clock end end end
Version data entries
11 entries across 11 versions & 1 rubygems