class FSEvent::SimpleDevice
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/>.
Attributes
Public Class Methods
FSEvent::AbstractDevice::new
# 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
Public Instance Methods
# 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
# File lib/fsevent/simpledevice.rb, line 43 def run(watched_status, changed_status) @run_block.call watched_status, changed_status end