Class: Observr::EventHandler::Portable
- Inherits:
-
Object
- Object
- Observr::EventHandler::Portable
- Includes:
- Base
- Defined in:
- lib/observr/event_handlers/portable.rb
Instance Method Summary collapse
-
#initialize ⇒ Portable
constructor
A new instance of Portable.
-
#listen(monitored_paths) ⇒ undefined
Enters listening loop.
-
#refresh(monitored_paths) ⇒ undefined
Update list of monitored paths.
-
#trigger ⇒ undefined
See if an event occured, and if so notify observers.
Methods included from Base
Constructor Details
#initialize ⇒ Portable
Returns a new instance of Portable.
6 7 8 |
# File 'lib/observr/event_handlers/portable.rb', line 6 def initialize @reference_mtime = @reference_atime = @reference_ctime = Time.now end |
Instance Method Details
#listen(monitored_paths) ⇒ undefined
Enters listening loop.
Will block control flow until application is explicitly stopped/killed.
19 20 21 22 |
# File 'lib/observr/event_handlers/portable.rb', line 19 def listen(monitored_paths) @monitored_paths = monitored_paths loop { trigger; sleep(1) } end |
#refresh(monitored_paths) ⇒ undefined
Update list of monitored paths.
41 42 43 |
# File 'lib/observr/event_handlers/portable.rb', line 41 def refresh(monitored_paths) @monitored_paths = monitored_paths end |
#trigger ⇒ undefined
See if an event occured, and if so notify observers.
29 30 31 32 |
# File 'lib/observr/event_handlers/portable.rb', line 29 def trigger path, type = detect_event notify(path, type) unless path.nil? end |