Module: Console::Clock
- Defined in:
- lib/console/clock.rb
Class Method Summary collapse
- .formatted_duration(duration) ⇒ Object
-
.now ⇒ Object
Get the current elapsed monotonic time.
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 |
.now ⇒ Object
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 |