Class: Inotify::Watcher
- Inherits:
-
Object
- Object
- Inotify::Watcher
- Defined in:
- lib/inotify-ffi.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Class Method Summary collapse
Instance Method Summary collapse
- #async_each_event(&blk) ⇒ Object
- #each_event ⇒ Object
-
#initialize(path, event_mask) ⇒ Watcher
constructor
A new instance of Watcher.
- #setup ⇒ Object
Constructor Details
#initialize(path, event_mask) ⇒ Watcher
Returns a new instance of Watcher.
20 21 22 |
# File 'lib/inotify-ffi.rb', line 20 def initialize(path, event_mask) @path, @event_mask = path, event_mask end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
23 24 25 |
# File 'lib/inotify-ffi.rb', line 23 def io @io end |
Class Method Details
.setup(path, event_mask) ⇒ Object
16 17 18 |
# File 'lib/inotify-ffi.rb', line 16 def self.setup(path, event_mask) new(path, event_mask).setup end |
Instance Method Details
#async_each_event(&blk) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/inotify-ffi.rb', line 39 def async_each_event(&blk) mod = Module.new do include Connection define_method(:notify_event, &blk) end EM.watch(@io, mod) do |c| c.notify_readable = true end end |
#each_event ⇒ Object
32 33 34 35 36 37 |
# File 'lib/inotify-ffi.rb', line 32 def each_event loop do ready = IO.select([ @io ], nil, nil, nil) yield Inotify.process_event(@fd) end end |