Class: ConradFiler::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/conrad_filer/rule.rb

Overview

A rule describes an action to perform on a file that matches one of its defined id types

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, a_hash) ⇒ Rule

Returns a new instance of Rule.



11
12
13
# File 'lib/conrad_filer/rule.rb', line 11

def initialize(db, a_hash)
  @db_rec = a_hash
end

Instance Attribute Details

#db_recObject

Returns the value of attribute db_rec.



9
10
11
# File 'lib/conrad_filer/rule.rb', line 9

def db_rec
  @db_rec
end

Instance Method Details

#get_id_type_namesObject



19
20
21
# File 'lib/conrad_filer/rule.rb', line 19

def get_id_type_names
  @db_rec['ID_TYPES']
end

#get_watch_job_namesObject



15
16
17
# File 'lib/conrad_filer/rule.rb', line 15

def get_watch_job_names
  @db_rec['WATCH_JOBS']
end

#nameObject



23
24
25
# File 'lib/conrad_filer/rule.rb', line 23

def name
  @db_rec['NAME']
end

#on_watch_event(watch_job, id_type, notify_event, path) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/conrad_filer/rule.rb', line 27

def on_watch_event(watch_job, id_type, notify_event, path)
  bitmask = Inotify::InotifyBitmask.new(notify_event.mask)
  if notify_event.name.class == String
    pathname = File.join(path, notify_event.name)
  else
    pathname = path
  end
  puts "[ConradRule::on_watch_event] '#{pathname}' #{bitmask.as_array_of_symbols}"
end