Method: Bind::Listener#initialize

Defined in:
lib/bind/listener.rb

#initialize(options = {}) ⇒ Listener

Event listener. Must specify the :paths, and :action options.

Options:

:paths           array of file or directory paths
:actions         objects responding to #call, which is used as the callbacks for the event handler
:timeout         time in seconds, after which the listener should stop. Defaults to 0, meaning infinity
:event           event to bind to, may be one of (:change). Defaults to :change
:debug           log verbose debugging information to this stream
:interval        sleep interval in seconds. Defaults to 2


27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bind/listener.rb', line 27

def initialize options = {}
  @run_time, @mtimes = 0, {}
  @paths = options.fetch :paths do
   raise ArgumentError, 'specify one or more :paths (or directories) to bind the listener to'
  end
  @actions = options.fetch :actions do
    raise ArgumentError, ':actions must be an array of objects responding to #call'
  end
  @log = options.fetch :debug, false
  @timeout = options.fetch :timeout, 0
  @interval = options.fetch :interval, 2
  @event = options.fetch :event, :change
end