module Console::Clock
A simple clock utility for tracking and formatting time.
Public Class Methods
Source
# File vendor/bundle/ruby/3.4.0/gems/console-1.30.2/lib/console/clock.rb, line 13 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
Format
a duration in seconds as a human readable string.
@parameter duration [Numeric] The duration in seconds. @returns [String] The formatted duration.
Source
# File vendor/bundle/ruby/3.4.0/gems/console-1.30.2/lib/console/clock.rb, line 36 def self.now ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) end
@returns [Time] The current monotonic time.