Class: FSEvent::AbstractDevice
- Inherits:
-
Object
- Object
- FSEvent::AbstractDevice
- Defined in:
- lib/fsevent/abstractdevice.rb
Overview
Abstract class for devices
Direct Known Subclasses
DebugDumper, FailSafeDevice, ProcessDevice, ProcessDeviceC, SimpleDevice
Instance Attribute Summary collapse
-
#framework ⇒ Object
writeonly
Sets the attribute framework.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#schedule ⇒ Object
readonly
Returns the value of attribute schedule.
Instance Method Summary collapse
- #add_watch(watchee_device_name_pat, status_name_pat, reaction = :immediate) ⇒ Object
- #define_status(status_name, value) ⇒ Object
- #del_watch(watchee_device_name_pat, status_name_pat) ⇒ Object
-
#initialize(device_name) ⇒ AbstractDevice
constructor
A new instance of AbstractDevice.
- #inspect ⇒ Object
- #modify_status(status_name, value) ⇒ Object
- #register_device(device) ⇒ Object
-
#registered ⇒ Object
Called from the framework when this device is registered.
-
#run(watched_status, changed_status) ⇒ Object
Called from the framework.
- #set_elapsed_time(t) ⇒ Object
- #undefine_status(status_name) ⇒ Object
- #unregister_device(device_name) ⇒ Object
-
#unregistered ⇒ Object
Called from the framework when this device is unregistered.
Constructor Details
#initialize(device_name) ⇒ AbstractDevice
Returns a new instance of AbstractDevice.
21 22 23 24 25 |
# File 'lib/fsevent/abstractdevice.rb', line 21 def initialize(device_name) @name = device_name @current_status = {} @schedule = FSEvent::ScheduleMerger.new end |
Instance Attribute Details
#framework=(value) ⇒ Object (writeonly)
Sets the attribute framework
27 28 29 |
# File 'lib/fsevent/abstractdevice.rb', line 27 def framework=(value) @framework = value end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
26 27 28 |
# File 'lib/fsevent/abstractdevice.rb', line 26 def name @name end |
#schedule ⇒ Object (readonly)
Returns the value of attribute schedule.
26 27 28 |
# File 'lib/fsevent/abstractdevice.rb', line 26 def schedule @schedule end |
Instance Method Details
#add_watch(watchee_device_name_pat, status_name_pat, reaction = :immediate) ⇒ Object
60 61 62 |
# File 'lib/fsevent/abstractdevice.rb', line 60 def add_watch(watchee_device_name_pat, status_name_pat, reaction = :immediate) @framework.add_watch(watchee_device_name_pat, status_name_pat, reaction) end |
#define_status(status_name, value) ⇒ Object
68 69 70 |
# File 'lib/fsevent/abstractdevice.rb', line 68 def define_status(status_name, value) @framework.define_status(status_name, value) end |
#del_watch(watchee_device_name_pat, status_name_pat) ⇒ Object
64 65 66 |
# File 'lib/fsevent/abstractdevice.rb', line 64 def del_watch(watchee_device_name_pat, status_name_pat) @framework.del_watch(watchee_device_name_pat, status_name_pat) end |
#inspect ⇒ Object
29 30 31 |
# File 'lib/fsevent/abstractdevice.rb', line 29 def inspect "\#<#{self.class}: #{@name}>" end |
#modify_status(status_name, value) ⇒ Object
72 73 74 |
# File 'lib/fsevent/abstractdevice.rb', line 72 def modify_status(status_name, value) @framework.modify_status(status_name, value) end |
#register_device(device) ⇒ Object
80 81 82 |
# File 'lib/fsevent/abstractdevice.rb', line 80 def register_device(device) @framework.register_device(device) end |
#registered ⇒ Object
Called from the framework when this device is registered.
34 35 36 37 38 39 40 41 42 |
# File 'lib/fsevent/abstractdevice.rb', line 34 def registered # child process calls: # * add_watch # * del_watch # possible but needless # * define_status # * modify_status # possible but needless # * undefine_status # possible but needless # * set_elapsed_time end |
#run(watched_status, changed_status) ⇒ Object
Called from the framework
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fsevent/abstractdevice.rb', line 49 def run(watched_status, changed_status) raise NotImplementedError # child process calls: # * add_watch # possible but should be rare # * del_watch # * define_status # possible but should be rare # * modify_status # * undefine_status # * set_elapsed_time end |
#set_elapsed_time(t) ⇒ Object
88 89 90 |
# File 'lib/fsevent/abstractdevice.rb', line 88 def set_elapsed_time(t) @framework.set_elapsed_time(t) end |
#undefine_status(status_name) ⇒ Object
76 77 78 |
# File 'lib/fsevent/abstractdevice.rb', line 76 def undefine_status(status_name) @framework.undefine_status(status_name) end |
#unregister_device(device_name) ⇒ Object
84 85 86 |
# File 'lib/fsevent/abstractdevice.rb', line 84 def unregister_device(device_name) @framework.unregister_device(device_name) end |
#unregistered ⇒ Object
Called from the framework when this device is unregistered.
45 46 |
# File 'lib/fsevent/abstractdevice.rb', line 45 def unregistered end |