Class: DirectoryWatcher::EmScanner::ScanTimer
- Inherits:
-
Object
- Object
- DirectoryWatcher::EmScanner::ScanTimer
- Defined in:
- lib/directory_watcher/em_scanner.rb
Overview
Periodically execute a Scan.
This object is used by EventableScanner to during shutdown.
Instance Method Summary collapse
-
#detach ⇒ Object
Detach the watcher from the event loop.
-
#initialize(scanner) ⇒ ScanTimer
constructor
A new instance of ScanTimer.
- #on_scan ⇒ Object
Constructor Details
#initialize(scanner) ⇒ ScanTimer
Returns a new instance of ScanTimer.
126 127 128 129 |
# File 'lib/directory_watcher/em_scanner.rb', line 126 def initialize( scanner ) @scanner = scanner @timer = EventMachine::PeriodicTimer.new( @scanner.interval, method(:on_scan) ) end |
Instance Method Details
#detach ⇒ Object
Detach the watcher from the event loop.
Required by EventableScanner as part of the shutdown process.
139 140 141 142 143 |
# File 'lib/directory_watcher/em_scanner.rb', line 139 def detach EventMachine.next_tick do @timer.cancel end end |
#on_scan ⇒ Object
131 132 133 |
# File 'lib/directory_watcher/em_scanner.rb', line 131 def on_scan @scanner.on_scan end |