Sinotify::PrimEvent is a ruby wrapper for an inotify event Use the Sinotify::PrimNotifier to register to listen for these Events.
Most users of Sinotify will not want to listen for prim events, instead opting to use a Sinotify::Notifier to listen for Sinotify::Events. See docs for those classes.
Methods :name, :mask, and :wd defined in sinotify.c
For convenience, inotify masks are represented in the PrimEvent as an ‘etype’, which is just a ruby symbol corresponding to the mask. For instance, a mask represented as Sinotify::MODIFY has an etype of :modify. You can still get the mask if you want the ‘raw’ int mask value. In other words:
$ irb >> require 'sinotify' => true >> Sinotify::MODIFY => 2 >> Sinotify::Event.etype_from_mask(Sinotify::MODIFY) => :modify >> Sinotify::Event.mask_from_etype(:modify) => 2
See docs for Sinotify::Event class for full list of supported event symbol types and their symbols.
Methods
public class
public instance
Public class methods
# File lib/sinotify/prim_event.rb, line 71 def self.all_etypes @@mask_to_etype_map.values.sort{|e1,e2| e1.to_s <=> e2.to_s} end
# File lib/sinotify/prim_event.rb, line 63 def self.etype_from_mask(mask) @@mask_to_etype_map[mask] end
# File lib/sinotify/prim_event.rb, line 67 def self.mask_from_etype(etype) @@etype_to_mask_map[etype] end
Public instance methods
# File lib/sinotify/prim_event.rb, line 99 def etypes @etypes ||= self.class.all_etypes.select{|et| self.has_etype?(et) } end
Return whether this event has etype specified
# File lib/sinotify/prim_event.rb, line 94 def has_etype?(etype) mask_for_etype = self.class.mask_from_etype(etype) return (self.mask & mask_for_etype).eql?(mask_for_etype) end
# File lib/sinotify/prim_event.rb, line 107 def inspect "<#{self.class} :name => '#{self.name}', :etypes => #{self.etypes.inspect}, :mask => #{self.mask.to_s(16)}, :watch_descriptor => #{self.watch_descriptor}>" end
# File lib/sinotify/prim_event.rb, line 83 def mask @mask ||= self.prim_mask end
# File lib/sinotify/prim_event.rb, line 75 def name @name ||= self.prim_name end
When first creating a watch, inotify sends a bunch of events that have masks don’t seem to match up w/ any of the masks defined in inotify.h. Pass on those.
# File lib/sinotify/prim_event.rb, line 89 def recognized? return !self.etypes.empty? end
# File lib/sinotify/prim_event.rb, line 103 def watch_descriptor self.wd end