Class: FSEvent::SimpleDevice
- Inherits:
-
AbstractDevice
- Object
- AbstractDevice
- FSEvent::SimpleDevice
- Defined in:
- lib/fsevent/simpledevice.rb
Overview
simpledevice.rb — simple device definition using constructor arguments
Copyright © 2014 National Institute of Advanced Industrial Science and Technology (AIST)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <www.gnu.org/licenses/>.
Instance Attribute Summary collapse
-
#registered_elapsed_time ⇒ Object
writeonly
Sets the attribute registered_elapsed_time.
Attributes inherited from AbstractDevice
Instance Method Summary collapse
-
#initialize(device_name, initial_status, watches, registered_elapsed_time, schedule = nil, &run_block) ⇒ SimpleDevice
constructor
A new instance of SimpleDevice.
- #registered ⇒ Object
- #run(watched_status, changed_status) ⇒ Object
Methods inherited from AbstractDevice
#add_watch, #define_status, #del_watch, #inspect, #modify_status, #register_device, #set_elapsed_time, #undefine_status, #unregister_device, #unregistered
Constructor Details
#initialize(device_name, initial_status, watches, registered_elapsed_time, schedule = nil, &run_block) ⇒ SimpleDevice
Returns a new instance of SimpleDevice.
19 20 21 22 23 24 25 26 27 |
# File 'lib/fsevent/simpledevice.rb', line 19 def initialize(device_name, initial_status, watches, registered_elapsed_time, schedule=nil, &run_block) super device_name @name = device_name @initial_status = initial_status @watches = watches @registered_elapsed_time = registered_elapsed_time @schedule.merge_schedule schedule if schedule @run_block = run_block end |
Instance Attribute Details
#registered_elapsed_time=(value) ⇒ Object (writeonly)
Sets the attribute registered_elapsed_time
28 29 30 |
# File 'lib/fsevent/simpledevice.rb', line 28 def registered_elapsed_time=(value) @registered_elapsed_time = value end |
Instance Method Details
#registered ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fsevent/simpledevice.rb', line 30 def registered @initial_status.each {|status_name, value| define_status status_name, value } @watches.each {|watchee_device_name, status_name, reaction| reaction ||= :immediate add_watch watchee_device_name, status_name, reaction } if @registered_elapsed_time set_elapsed_time @registered_elapsed_time end end |
#run(watched_status, changed_status) ⇒ Object
43 44 45 |
# File 'lib/fsevent/simpledevice.rb', line 43 def run(watched_status, changed_status) @run_block.call watched_status, changed_status end |