Class: ConradFiler::Rule
- Inherits:
-
Object
- Object
- ConradFiler::Rule
- 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
-
#db_rec ⇒ Object
Returns the value of attribute db_rec.
Instance Method Summary collapse
- #get_id_type_names ⇒ Object
- #get_watch_job_names ⇒ Object
-
#initialize(db, a_hash) ⇒ Rule
constructor
A new instance of Rule.
- #name ⇒ Object
- #on_watch_event(watch_job, id_type, notify_event, path) ⇒ Object
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_rec ⇒ Object
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_names ⇒ Object
19 20 21 |
# File 'lib/conrad_filer/rule.rb', line 19 def get_id_type_names @db_rec['ID_TYPES'] end |
#get_watch_job_names ⇒ Object
15 16 17 |
# File 'lib/conrad_filer/rule.rb', line 15 def get_watch_job_names @db_rec['WATCH_JOBS'] end |
#name ⇒ Object
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 |