Class: Winker::Device
- Inherits:
-
Object
- Object
- Winker::Device
- Includes:
- Winker::Devices::DeviceMethods, Winker::Devices::Eggtray, Winker::Devices::GenericDevice, Winker::Devices::Hub, Winker::Devices::LightBulb, Winker::Devices::OnOff, Winker::Devices::SensorPod, Winker::Devices::UnknownDevice
- Defined in:
- lib/winker/device.rb
Constant Summary
Constants included from Winker::Devices::DeviceMethods
Winker::Devices::DeviceMethods::VALID_TYPES, Winker::Devices::DeviceMethods::WAIT_BLOCK_SLEEP, Winker::Devices::DeviceMethods::WAIT_BLOCK_TIMEOUT
Instance Attribute Summary
Attributes included from Winker::Devices::DeviceMethods
#id, #obj_data, #type, #updated_at
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(obj_data) ⇒ Device
constructor
A new instance of Device.
- #method_missing(method_sym, *arguments, &block) ⇒ Object
Methods included from Winker::Devices::Hub
Methods included from Winker::Devices::Eggtray
#count, #days_left, #eggs_expired, #eggs_left, #eggs_warning, #expire_time, #warning_time
Methods included from Winker::Devices::UnknownDevice
Methods included from Winker::Devices::SensorPod
Methods included from Winker::Devices::LightBulb
#brightness, #brightness=, #check_last_brightness, extended, #updates_finished?
Methods included from Winker::Devices::OnOff
#check_last_powered, #off, #off?, #on, #powered?, #updates_finished?
Methods included from Winker::Devices::GenericDevice
Methods included from Winker::Devices::DeviceMethods
#find_type_and_id, #wait_for_update
Constructor Details
#initialize(obj_data) ⇒ Device
Returns a new instance of Device.
17 18 19 20 21 |
# File 'lib/winker/device.rb', line 17 def initialize(obj_data) @obj_data = obj_data find_type_and_id self.extend(eval("Winker::Devices::#{@type.classify}")) if @type end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/winker/device.rb', line 23 def method_missing(method_sym, *arguments, &block) if obj_data.respond_to?(method_sym) obj_data.send(method_sym, *arguments, &block) else super end end |