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
| 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # File 'lib/console/clock.rb', line 25 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.
| 48 49 50 | # File 'lib/console/clock.rb', line 48 def self.now ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) end |