Module: Timeouter

Defined in:
lib/timeouter.rb,
lib/timeouter/timer.rb,
lib/timeouter/version.rb

Defined Under Namespace

Classes: Timer

Constant Summary collapse

TimeoutError =
Timeout::Error
VERSION =
'0.1.3'.freeze

Class Method Summary collapse

Class Method Details

.loop(timeout = 0, eclass: Timeouter::TimeoutError, message: 'execution expired', &block) ⇒ Object



14
15
16
# File 'lib/timeouter.rb', line 14

def loop(timeout = 0, eclass: Timeouter::TimeoutError, message: 'execution expired', &block)
  Timeouter::Timer.new(timeout, eclass: eclass, message: message).loop(&block)
end

.loop!(timeout = 0, eclass: Timeouter::TimeoutError, message: 'execution expired', &block) ⇒ Object



18
19
20
# File 'lib/timeouter.rb', line 18

def loop!(timeout = 0, eclass: Timeouter::TimeoutError, message: 'execution expired', &block)
  Timeouter::Timer.new(timeout, eclass: eclass, message: message).loop!(&block)
end

.run(timeout = 0, eclass: Timeouter::TimeoutError, message: 'execution expired') {|Timeouter::Timer.new(timeout, eclass: eclass, message: message)| ... } ⇒ Object

Yields:



10
11
12
# File 'lib/timeouter.rb', line 10

def run(timeout = 0, eclass: Timeouter::TimeoutError, message: 'execution expired')
  yield(Timeouter::Timer.new(timeout, eclass: eclass, message: message))
end