Module: Utils::Timer

Defined in:
utils/timer.rb

Class Method Summary collapse

Class Method Details

.remaining(time) ⇒ Float, ...

Parameters:

Returns:

  • (Float, Integer, nil)


7
8
9
10
11
# File 'utils/timer.rb', line 7

def self.remaining(time)
  return unless time

  [0, time - Time.now].max
end

.remaining!(time) ⇒ Float, ...

Parameters:

Returns:

  • (Float, Integer, nil)

Raises:

  • (Timeout::Error)


14
15
16
17
18
19
# File 'utils/timer.rb', line 14

def self.remaining!(time)
  r = remaining(time)
  raise Timeout::Error if r && r <= 0

  r
end