Module: LoopHard::TimeoutTrap

Defined in:
lib/loop_hard/timeout_trap.rb

Class Method Summary collapse

Class Method Details

.continue?(options) ⇒ Boolean

Returns false if the timeout has expired. True otherwise. Expects an options has with a ‘maximum_end_time` key.

Returns:

  • (Boolean)


7
8
9
10
11
12
13
# File 'lib/loop_hard/timeout_trap.rb', line 7

def continue?(options)
  if options[:maximum_end_time] && Time.now > options[:maximum_end_time]
    LoopHard.logger.info "Ending loop due to timeout"
    return false
  end
  return true
end