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