Module: Process
- Defined in:
- lib/timecop/time_extensions.rb
Overview
:nodoc:
Class Method Summary collapse
- .clock_gettime_mock_time(clock_id, unit = :float_second) ⇒ Object (also: clock_gettime)
Class Method Details
.clock_gettime_mock_time(clock_id, unit = :float_second) ⇒ Object Also known as: clock_gettime
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/timecop/time_extensions.rb', line 176 def clock_gettime_mock_time(clock_id, unit = :float_second) mock_time = case clock_id when Process::CLOCK_MONOTONIC mock_time_monotonic when Process::CLOCK_REALTIME mock_time_realtime end return clock_gettime_without_mock(clock_id, unit) unless Timecop.mock_process_clock? && mock_time divisor = case unit when :float_second 1_000_000_000.0 when :second 1_000_000_000 when :float_millisecond 1_000_000.0 when :millisecond 1_000_000 when :float_microsecond 1000.0 when :microsecond 1000 when :nanosecond 1 end (mock_time / divisor) end |