class Domotics::Core::Setup
Public Class Methods
logger()
click to toggle source
# File lib/domotics/core/setup.rb, line 7 def self.logger @@logger end
logger=(logger)
click to toggle source
# File lib/domotics/core/setup.rb, line 10 def self.logger=(logger) @@logger = logger end
new(conf)
click to toggle source
# File lib/domotics/core/setup.rb, line 14 def initialize(conf) @current_room = {} @current_device = {} @groups = [] instance_eval conf, __FILE__, __LINE__ end
Public Instance Methods
device(klass, args = {}) { || ... }
click to toggle source
# File lib/domotics/core/setup.rb, line 41 def device(klass, args = {}) @current_device[:name] = args[:name] @current_device[:type] = args[:type] args[:room] = Room[@current_room[:name]] klass.new(args) unless Device[args[:name]] yield if ::Kernel.block_given? @current_device.clear end
element(klass, args = {})
click to toggle source
# File lib/domotics/core/setup.rb, line 50 def element(klass, args = {}) raise "Element must have room" unless @current_room.any? args[:room] = Room[@current_room[:name]] args[:room_type] = @current_room[:type] args[:device] = Device[@current_device[:name]] args[:device_type] = @current_device[:type] klass = klass.dup if args[:device_type] el = klass.new(args) unless Room[@current_room[:name]][args[:name]] @groups[-1].add_element el if @groups[-1] end
element_group(args = {}) { || ... }
click to toggle source
# File lib/domotics/core/setup.rb, line 21 def element_group(args = {}) raise "Element group must have room" unless @current_room.any? args[:room] = @current_room[:name] unless gr = Room[@current_room[:name]][args[:name]] gr = ElementGroup.new args @groups[-1].add_element gr if @groups[-1] end @groups.push(gr) yield if ::Kernel.block_given? @groups.pop end
method_missing(symbol, *args, &block)
click to toggle source
Calls superclass method
# File lib/domotics/core/setup.rb, line 61 def method_missing(symbol, *args, &block) if CLASS_MAP[symbol] and name = args.shift args_hash = args.shift || {} args_hash[:name] = name args_hash[:type] = symbol if CLASS_MAP[symbol][0] != :element args_hash[:logger] = @@logger __send__(*CLASS_MAP[symbol], args_hash, &block) else super end end
room(klass, args = {}) { || ... }
click to toggle source
# File lib/domotics/core/setup.rb, line 33 def room(klass, args = {}) @current_room[:name] = args[:name] @current_room[:type] = args[:type] klass.new(args) unless Room[args[:name]] yield if ::Kernel.block_given? @current_room.clear end