Class: Inotify::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/inotify-ffi.rb

Instance Method Summary collapse

Constructor Details

#initialize(struct, buf) ⇒ Event

Returns a new instance of Event.



68
69
70
# File 'lib/inotify-ffi.rb', line 68

def initialize(struct, buf)
  @struct, @buf = struct, buf
end

Instance Method Details

#inspectObject



80
81
82
83
84
85
86
87
# File 'lib/inotify-ffi.rb', line 80

def inspect
  "<%s: wd:%s mask:%s len=%s>" % [
    name,
    @struct[:wd],
    @struct[:mask],
    @struct[:len]
  ]
end

#is?(*c) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/inotify-ffi.rb', line 76

def is?(*c)
  c.all? {|c| (mask & c) > 0 }
end

#lenObject



74
# File 'lib/inotify-ffi.rb', line 74

def len  ; @struct[:len]  ; end

#maskObject



72
# File 'lib/inotify-ffi.rb', line 72

def mask ; @struct[:mask] ; end

#mask_namesObject



89
90
91
92
93
94
# File 'lib/inotify-ffi.rb', line 89

def mask_names
  Const.constants.select do |const|
    value = Const.const_get(const)
    @struct[:mask] & value > 0
  end
end

#nameObject



96
97
98
# File 'lib/inotify-ffi.rb', line 96

def name
  @struct[:len] >= 0 ? @buf.get_string(@struct[:len]) : '<unknown>'
end

#wdObject



73
# File 'lib/inotify-ffi.rb', line 73

def wd   ; @struct[:wd]   ; end