Module: Since

Defined in:
lib/since.rb

Overview

Simplest 'how long has it been sinceā€¦?' possible.

Class Method Summary collapse

Class Method Details

.nowTime

Mark the time.


5
6
7
8
# File 'lib/since.rb', line 5

def self.now
  @@clock = Time.now
  @@clock
end

.then(fmt = '%Hh %Mm %Ss') ⇒ String

Create a timestamp of the total duration since we marked the time.


19
20
21
# 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?Time

When did we mark the time?


12
13
14
# File 'lib/since.rb', line 12

def self.when?
  @@clock
end