Class: Frontman::Toolbox::Timer

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/frontman/toolbox/timer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.startObject



12
13
14
15
16
# File 'lib/frontman/toolbox/timer.rb', line 12

def self.start
  timer = new
  timer.begin
  timer
end

Instance Method Details

#beginObject



19
20
21
# File 'lib/frontman/toolbox/timer.rb', line 19

def begin
  @start = Time.now
end

#diffObject



29
30
31
# File 'lib/frontman/toolbox/timer.rb', line 29

def diff
  @end - @start
end

#ended_atObject



39
40
41
# File 'lib/frontman/toolbox/timer.rb', line 39

def ended_at
  @end
end

#outputObject



44
45
46
# File 'lib/frontman/toolbox/timer.rb', line 44

def output
  "Elapsed time: ~#{(diff * 1000).ceil} milliseconds.\n"
end

#started_atObject



34
35
36
# File 'lib/frontman/toolbox/timer.rb', line 34

def started_at
  @start
end

#stopObject



24
25
26
# File 'lib/frontman/toolbox/timer.rb', line 24

def stop
  @end = Time.now
end