Class: Inotify::Event

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

Overview

The Inotify::Event class is used by Inotify when calling Inotify each_event method

Instance Method Summary collapse

Constructor Details

#initialize(struct, buf) ⇒ Event

:nodoc:



144
145
146
# File 'lib/inotify/inotify_native.rb', line 144

def initialize(struct, buf) # :nodoc:
  @struct, @buf = struct, buf
end

Instance Method Details

Returns the cookie associated with the event. If multiple events are triggered from the same action (such as renaming a file or directory), this value will be the same.



160
161
162
# File 'lib/inotify/inotify_native.rb', line 160

def cookie
  @struct[:cookie]
end

#inspectObject

:nodoc:



173
174
175
176
177
178
179
180
# File 'lib/inotify/inotify_native.rb', line 173

def inspect # :nodoc:
  "<%s name=%s mask=%s wd=%s>" % [
    self.class,
    self.name,
    self.mask,
    self.wd
  ]
end

#lenObject

:nodoc:



164
165
166
# File 'lib/inotify/inotify_native.rb', line 164

def len # :nodoc:
  @struct[:len]
end

#maskObject

Returns the mask describing the event



154
155
156
# File 'lib/inotify/inotify_native.rb', line 154

def mask
  @struct[:mask]
end

#nameObject

Returns the file name associated with the event, if applicable



169
170
171
# File 'lib/inotify/inotify_native.rb', line 169

def name
  @struct[:len] > 0 ? @buf.get_string(16, @struct[:len]) : ''
end

#wdObject

Returns the watch descriptor (wd) associated with the event



149
150
151
# File 'lib/inotify/inotify_native.rb', line 149

def wd
  @struct[:wd]
end