Module: Domotics::Core

Defined in:
lib/domotics/core.rb,
lib/domotics/core/room.rb,
lib/domotics/core/setup.rb,
lib/domotics/core/device.rb,
lib/domotics/core/server.rb,
lib/domotics/core/element.rb,
lib/domotics/core/version.rb,
lib/domotics/core/ws_server.rb,
lib/domotics/core/element_group.rb,
lib/domotics/core/helper/helper.rb,
lib/domotics/core/helper/helper.rb,
lib/domotics/core/helper/helper.rb,
lib/domotics/core/data/data_hash.rb,
lib/domotics/core/element/button.rb,
lib/domotics/core/element/dimmer.rb,
lib/domotics/core/element/switch.rb,
lib/domotics/core/data/data_mongo.rb,
lib/domotics/core/data/data_redis.rb,
lib/domotics/core/element/rgb_strip.rb,
lib/domotics/core/element/reed_switch.rb,
lib/domotics/core/device/arduino_board.rb,
lib/domotics/core/element/motion_sensor.rb,
lib/domotics/core/device/file_camera_device.rb

Defined Under Namespace

Classes: ArduinoBoard, BlackHole, Button, DataHash, DataHashOperator, DataMongo, DataMongoOperator, DataRedis, DataRedisOperator, Device, Dimmer, Element, ElementGroup, FileCameraDevice, MotionSensor, ReedSwitch, RgbStrip, Room, Server, Setup, Switch, TestHelper, TestRoom, WsServer

Constant Summary collapse

CLASS_MAP =

Map config names to real classes

{}
VERSION =
"0.2.8"

Class Method Summary collapse

Class Method Details

.add_map(args = {}) ⇒ Object

Scan file for class name and add to CLASS_MAP



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/domotics/core.rb', line 24

def self.add_map(args = {})
  realm = args[:realm] || self
  if args[:file]
    class_name = nil
    index = nil
    require args[:file]
    IO.read(args[:file]).each_line do |line|
      if line =~ /class\s*([A-Z]\w*)[\s\w<]*(#__as__ :(\w*))?/
        class_name, index = $1, $3 && $3.to_sym
        break
      end
    end
    return unless class_name
  end
  class_name ||= args[:class_name]
  index ||= class_name.split(/(?=[A-Z])/).map{ |cnp| cnp.downcase }.join('_').to_sym
  klass = realm.const_get(class_name)
  CLASS_MAP[index] = [args[:type], klass]
end