Module: TriggerSwitchD

Defined in:
lib/trigger_switch_d/ipc.rb,
lib/trigger_switch_d/action.rb,
lib/trigger_switch_d/config.rb,
lib/trigger_switch_d/switch.rb,
lib/trigger_switch_d/schedule.rb,
lib/trigger_switch_d/application.rb,
lib/trigger_switch_d/trigger_switch_d_helper.rb

Overview

TriggerSwitchD, executes commands to activate/deactive remote switches. © Copyright 2010 Pontus Strömdahl, AdhocSkill.

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/>.

Defined Under Namespace

Modules: ConfigFactory, IPC, Schedule, SwitchFactory Classes: Action, Application

Class Method Summary collapse

Class Method Details

.load_devices(file) ⇒ Object

Returns devices loaded from file



29
30
31
32
33
34
35
36
# File 'lib/trigger_switch_d/trigger_switch_d_helper.rb', line 29

def self.load_devices(file)
  devices = YAML::load(file)
  SwitchFactory.new(devices[0]["switches"][0].keys)
  devices.inject({}) do |result, device|
    result[device["name"]] = TriggerSwitchD::map_switches(device["switches"])
    result
  end
end

.load_scheduled_actions(file, date = Date.today) ⇒ Object

Loads up schedule with the actions in file



21
22
23
24
25
26
# File 'lib/trigger_switch_d/trigger_switch_d_helper.rb', line 21

def self.load_scheduled_actions(file,date=Date.today)
  rows = file.readlines
  rows.each do |code_line|
    yield(code_line, date)
  end
end