Class: Monotonik::ClockTime

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/monotonik/clock_time.rb

Overview

Class to get monotonic clock time.

Constant Summary collapse

DEFAULT_TIME_UNIT =
TimeUnits::FLOAT_SECOND

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.now(unit = DEFAULT_TIME_UNIT) ⇒ Object

See Also:



30
# File 'lib/monotonik/clock_time.rb', line 30

def_delegator :instance, :now

Instance Method Details

#now(unit = DEFAULT_TIME_UNIT) ⇒ Float|Integer

Returns a monotonic clock time returned by POSIX ::clock_gettime() function.

Parameters:

  • unit (Symbol) (defaults to: DEFAULT_TIME_UNIT)

    Specifies a type of the return value, can be any value from ‘Monotonik::TimeUnits::ALL`.

Returns:

  • (Float|Integer)

    A monotonic clock time returned by POSIX ::clock_gettime() function.

Raises:

  • (ArgumentError)

    When unexpected ‘unit’ value is given.



40
41
42
# File 'lib/monotonik/clock_time.rb', line 40

def now(unit = DEFAULT_TIME_UNIT)
  Process.clock_gettime(Process::CLOCK_MONOTONIC, unit)
end