module INotify::Native::Flags

A module containing all the inotify flags to be passed to {Notifier#watch}.

@private

Constants

IN_ACCESS

File was accessed.

IN_ALL_EVENTS

All events which a program can wait on.

IN_ATTRIB

Metadata changed.

IN_CLOSE

Close.

IN_CLOSE_NOWRITE

Unwrittable file closed.

IN_CLOSE_WRITE

Writtable file was closed.

IN_CREATE

Subfile was created.

IN_DELETE

Subfile was deleted.

IN_DELETE_SELF

Self was deleted.

IN_DONT_FOLLOW

Do not follow a sym link.

IN_IGNORED

File was ignored.

IN_ISDIR

Event occurred against dir.

IN_MASK_ADD

Add to the mask of an already existing watch.

IN_MODIFY

File was modified.

IN_MOVE

Moves.

IN_MOVED_FROM

File was moved from X.

IN_MOVED_TO

File was moved to Y.

IN_MOVE_SELF

Self was moved.

IN_ONESHOT

Only send event once.

IN_ONLYDIR

Only watch the path if it is a directory.

IN_OPEN

File was opened.

IN_Q_OVERFLOW

Event queued overflowed.

IN_UNMOUNT

Backing fs was unmounted.

Public Class Methods

from_mask(mask) click to toggle source

Converts a bitmask from the C API into a list of flags.

@param mask [Fixnum] @return [Array<Symbol>]

# File lib/rb-inotify/native/flags.rb, line 81
def self.from_mask(mask)
  constants.map {|c| c.to_s}.select do |c|
    next false unless c =~ /^IN_/
    const_get(c) & mask != 0
  end.map {|c| c.sub("IN_", "").downcase.to_sym} - [:all_events]
end
to_mask(flags) click to toggle source

Converts a list of flags to the bitmask that the C API expects.

@param flags [Array<Symbol>] @return [Fixnum]

# File lib/rb-inotify/native/flags.rb, line 72
def self.to_mask(flags)
  flags.map {|flag| const_get("IN_#{flag.to_s.upcase}")}.
    inject(0) {|mask, flag| mask | flag}
end