Class: INotify::Watcher
- Inherits:
-
Object
- Object
- INotify::Watcher
- Defined in:
- lib/rb-inotify/watcher.rb
Overview
Watchers monitor a single path for changes, specified by event flags. A watcher is usually created via Notifier#watch.
One Notifier may have many Watchers. The Notifier actually takes care of the checking for events, via #run or #process. The main purpose of having Watcher objects is to be able to disable them using #close.
Instance Attribute Summary (collapse)
-
- (Array<Symbol>) flags
readonly
The flags specifying the events that this Watcher is watching for, and potentially some options as well.
-
- (Notifier) notifier
readonly
The Notifier that this Watcher belongs to.
-
- (String) path
readonly
The path that this Watcher is watching.
Instance Method Summary (collapse)
-
- (Object) close
Disables this Watcher, so that it doesn't fire any more events.
Instance Attribute Details
- (Array<Symbol>) flags (readonly)
The flags specifying the events that this Watcher is watching for, and potentially some options as well.
27 28 29 |
# File 'lib/rb-inotify/watcher.rb', line 27 def flags @flags end |
- (Notifier) notifier (readonly)
The Notifier that this Watcher belongs to.
15 16 17 |
# File 'lib/rb-inotify/watcher.rb', line 15 def notifier @notifier end |
- (String) path (readonly)
The path that this Watcher is watching.
20 21 22 |
# File 'lib/rb-inotify/watcher.rb', line 20 def path @path end |
Instance Method Details
- (Object) close
Disables this Watcher, so that it doesn't fire any more events.
47 48 49 50 |
# File 'lib/rb-inotify/watcher.rb', line 47 def close return if Native.inotify_rm_watch(@notifier.fd, @id) == 0 raise SystemCallError.new("Failed to stop watching #{path.inspect}", FFI.errno) end |