Module: TimeLimits::Timeout

Extended by:
Timeout
Included in:
Timeout
Defined in:
lib/time_limits/timeout.rb

Instance Method Summary collapse

Instance Method Details

#in_time(duration = 1, &block) ⇒ Object



11
12
13
# File 'lib/time_limits/timeout.rb', line 11

def in_time( duration = 1, &block )
  SystemTimer.timeout_after(duration) { yield }
end

#in_time_or_else(duration = 1, options = {}, &block) ⇒ Object

options :rescue value



24
25
26
27
28
# File 'lib/time_limits/timeout.rb', line 24

def in_time_or_else( duration = 1, options = {}, &block )
  in_time( duration, &block )
rescue ::Timeout::Error => x
  return options[:rescue]
end