Method: Collective::Idler#initialize

Defined in:
lib/collective/idler.rb

#initialize(callable = nil, options = {}, &callable_block) ⇒ Idler

Returns a new instance of Idler.



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/collective/idler.rb', line 19

def initialize( callable = nil, options = {}, &callable_block )
  @callable = callable || callable_block
  raise unless @callable.respond_to?(:call)

  @max_sleep = options[:max_sleep] || MAX_SLEEP
  raise if @max_sleep <= 0

  @min_sleep = options[:min_sleep] || MIN_SLEEP
  raise if @min_sleep <= 0
  raise if @max_sleep < @min_sleep

  @sleep     = nil
end