Class: FSEvent::AbstractDevice
- Inherits:
-
Object
- Object
- FSEvent::AbstractDevice
- Defined in:
- lib/fsevent/abstractdevice.rb
Overview
Abstract class for devices
Direct Known Subclasses
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, status_name, reaction = :immediate) ⇒ Object
- #define_status(status_name, value) ⇒ Object
-
#initialize(device_name) ⇒ AbstractDevice
constructor
A new instance of AbstractDevice.
-
#registered ⇒ Object
Called from the framework when this device is registered.
-
#run(watched_status_change) ⇒ Object
Called from the framework.
- #set_elapsed_time(t) ⇒ Object
- #status_changed(status_name, value) ⇒ 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, status_name, reaction = :immediate) ⇒ Object
52 53 54 |
# File 'lib/fsevent/abstractdevice.rb', line 52 def add_watch(watchee_device_name, status_name, reaction = :immediate) @framework.add_watch(watchee_device_name, status_name, reaction) end |
#define_status(status_name, value) ⇒ Object
56 57 58 |
# File 'lib/fsevent/abstractdevice.rb', line 56 def define_status(status_name, value) @framework.define_status(status_name, value) end |
#registered ⇒ Object
Called from the framework when this device is registered.
30 31 32 33 34 35 36 |
# File 'lib/fsevent/abstractdevice.rb', line 30 def registered # child process calls: # * @framework.add_watch # * @framework.define_status # * @framework.status_changed # possible but needless # * @framework.set_elapsed_time end |
#run(watched_status_change) ⇒ Object
Called from the framework
43 44 45 46 47 48 49 50 |
# File 'lib/fsevent/abstractdevice.rb', line 43 def run(watched_status_change) raise NotImplementedError # child process calls: # * @framework.add_watch # possible but should be rare # * @framework.define_status # possible but should be rare # * @framework.status_changed # * @framework.set_elapsed_time end |
#set_elapsed_time(t) ⇒ Object
68 69 70 |
# File 'lib/fsevent/abstractdevice.rb', line 68 def set_elapsed_time(t) @framework.set_elapsed_time(t) end |
#status_changed(status_name, value) ⇒ Object
60 61 62 |
# File 'lib/fsevent/abstractdevice.rb', line 60 def status_changed(status_name, value) @framework.status_changed(status_name, value) end |
#unregister_device(device_name) ⇒ Object
64 65 66 |
# File 'lib/fsevent/abstractdevice.rb', line 64 def unregister_device(device_name) @framework.unregister_device(device_name) end |
#unregistered ⇒ Object
Called from the framework when this device is unregistered.
39 40 |
# File 'lib/fsevent/abstractdevice.rb', line 39 def unregistered end |