module Since

Simplest ‘how long has it been since…?’ possible.

Public Class Methods

now() click to toggle source

Mark the time. @return [Void]

# File lib/since.rb, line 5
def self.now
  @@clock = Time.now
  @@clock
end
then(fmt = '%Hh %Mm %Ss') click to toggle source

Create a timestamp of the total duration since we marked the time. @param fmt [String] format string for {Time#strftime} @return [String]

# File lib/since.rb, line 19
def self.then fmt = '%Hh %Mm %Ss'
  Time.at((Time.now - @@clock).to_i.abs).utc.strftime fmt
end
when?() click to toggle source

When did we mark the time? @return [Time]

# File lib/since.rb, line 12
def self.when?
  @@clock
end