module Ur::Metadata
Attributes
began_at_ns[RW]
Public Instance Methods
began_at()
click to toggle source
# File lib/ur/metadata.rb, line 9 def began_at began_at_s ? Time.parse(began_at_s) : nil end
began_at=(time)
click to toggle source
# File lib/ur/metadata.rb, line 12 def began_at=(time) self.began_at_s = time ? time.utc.iso8601(6) : nil end
begin!()
click to toggle source
sets began_at
from the current time
# File lib/ur/metadata.rb, line 19 def begin! self.began_at = Time.now self.began_at_ns = Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond) end
finish!()
click to toggle source
sets the duration from the current time and began_at
# File lib/ur/metadata.rb, line 25 def finish! return if duration if began_at_ns now_ns = Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond) self.duration = (now_ns - began_at_ns) * 1e-9 elsif began_at now = Time.now self.duration = (now.to_f - began_at.to_f) end end