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
| 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # File 'lib/console/clock.rb', line 8 def self.formatted_duration(duration) if duration < 60.0 return "#{duration.round(2)}s" end duration /= 60.0 if duration < 60.0 return "#{duration.floor}m" end duration /= 60.0 if duration < 24.0 return "#{duration.floor}h" end duration /= 24.0 return "#{duration.floor}d" end | 
.now ⇒ Object
Get the current elapsed monotonic time.
| 31 32 33 | # File 'lib/console/clock.rb', line 31 def self.now ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) end |