Class: DirectoryWatcher::EmScanner::Watcher
- Inherits:
-
EventMachine::FileWatch
- Object
- EventMachine::FileWatch
- DirectoryWatcher::EmScanner::Watcher
- 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
- #active? ⇒ Boolean
- #event! ⇒ Object (also: #file_modified, #file_moved)
- #file_deleted ⇒ Object
-
#initialize(scanner) ⇒ Watcher
constructor
A new instance of Watcher.
- #stat ⇒ Object
- #unbind ⇒ Object
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
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_deleted ⇒ Object
211 |
# File 'lib/directory_watcher/em_scanner.rb', line 211 def file_deleted() EventMachine.next_tick {event!}; end |
#stat ⇒ Object
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 |
#unbind ⇒ Object
210 |
# File 'lib/directory_watcher/em_scanner.rb', line 210 def unbind() @active = false; end |