Module: Console::Clock

Defined in:
lib/console/clock.rb

Class Method Summary collapse

Class Method Details

.formatted_duration(duration) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/console/clock.rb', line 23

def self.formatted_duration(duration)
	if duration < 60.0
		return "#{duration.round(2)}s"
	end
	
	duration /= 60.0
	
	if duration < 60.0
		return "#{duration.round}m"
	end
	
	duration /= 60.0
	
	if duration < 60.0
		return "#{duration.round(1)}h"
	end
	
	duration /= 24.0
	
	return "#{duration.round(1)}d"
end

.nowObject

Get the current elapsed monotonic time.



46
47
48
# File 'lib/console/clock.rb', line 46

def self.now
	::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
end