Parent

Methods

DirectoryWatcher::Notifier

A Notifier pull Event instances from the give queue and sends them to all of the Observers it knows about.

Public Class Methods

new( config, observers ) click to toggle source

Create a new Notifier that pulls events off the given notification_queue from the config, and sends them to the listed observers.

# File lib/directory_watcher/notifier.rb, line 11
def initialize( config, observers )
  @config = config
  @observers = observers
  self.interval = 0.01 # yes this is a fast loop
end

Public Instance Methods

run() click to toggle source

Notify all the observers of all the available events in the queue. If there are 2 or more events in a row that are the same, then they are collapsed into a single event.

# File lib/directory_watcher/notifier.rb, line 21
def run
  previous_event = nil
  until queue.empty? do
    event = queue.deq
    next if previous_event == event
    @observers.each do |observer, func|
      send_event_to_observer( observer, func, event )
    end
    previous_event = event
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.