Class Sinotify::PrimEvent

  1. lib/sinotify/prim_event.rb
Parent: Object

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.

Public class methods

all_etypes ()
[show source]
# 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
etype_from_mask (mask)
[show source]
# File lib/sinotify/prim_event.rb, line 63
    def self.etype_from_mask(mask)
      @@mask_to_etype_map[mask]
    end
mask_from_etype (etype)
[show source]
# File lib/sinotify/prim_event.rb, line 67
    def self.mask_from_etype(etype)
      @@etype_to_mask_map[etype]
    end

Public instance methods

etypes ()
[show source]
# File lib/sinotify/prim_event.rb, line 99
    def etypes
      @etypes ||= self.class.all_etypes.select{|et| self.has_etype?(et) }
    end
has_etype? (etype)

Return whether this event has etype specified

[show source]
# 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
inspect ()
[show source]
# 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
mask ()
[show source]
# File lib/sinotify/prim_event.rb, line 83
    def mask
      @mask ||= self.prim_mask
    end
name ()
[show source]
# File lib/sinotify/prim_event.rb, line 75
    def name
      @name ||= self.prim_name
    end
recognized? ()

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.

[show source]
# File lib/sinotify/prim_event.rb, line 89
    def recognized?
      return !self.etypes.empty?
    end
watch_descriptor ()
[show source]
# File lib/sinotify/prim_event.rb, line 103
    def watch_descriptor
      self.wd
    end
wd ()
[show source]
# File lib/sinotify/prim_event.rb, line 79
    def wd
      @wd ||= self.prim_wd
    end