Class: DirectoryWatcher::EmScanner::ScanTimer

Inherits:
Object
  • Object
show all
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

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

#detachObject

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_scanObject



131
132
133
# File 'lib/directory_watcher/em_scanner.rb', line 131

def on_scan
  @scanner.on_scan
end