Class: DirectoryWatcher::EmScanner::Watcher

Inherits:
EventMachine::FileWatch
  • Object
show all
Defined in:
lib/directory_watcher/em_scanner.rb

Overview

:stopdoc:

This is our tailored implementation of the EventMachine FileWatch class. It receives notifications of file events and provides a mechanism to translate the EventMachine events into DirectoryWatcher events.

Instance Method Summary collapse

Constructor Details

#initialize(scanner) ⇒ Watcher

Returns a new instance of Watcher.



197
198
199
200
# File 'lib/directory_watcher/em_scanner.rb', line 197

def initialize( scanner )
  @scanner = scanner
  @active = true
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


208
# File 'lib/directory_watcher/em_scanner.rb', line 208

def active?() @active; end

#event!Object Also known as: file_modified, file_moved



209
# File 'lib/directory_watcher/em_scanner.rb', line 209

def event!() @scanner._event!(self); end

#file_deletedObject



211
# File 'lib/directory_watcher/em_scanner.rb', line 211

def file_deleted() EventMachine.next_tick {event!}; end

#statObject



202
203
204
205
206
# File 'lib/directory_watcher/em_scanner.rb', line 202

def stat
  return unless test ?e, @path
  stat = File.stat @path
  ::DirectoryWatcher::FileStat.new(stat.mtime, stat.size, @scanner.stable)
end

#unbindObject



210
# File 'lib/directory_watcher/em_scanner.rb', line 210

def unbind() @active = false; end