Class: MiOS::Device
- Inherits:
-
Object
show all
- Defined in:
- lib/mios/device.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(interface, status_info) ⇒ Device
5
6
7
8
9
|
# File 'lib/mios/device.rb', line 5
def initialize(interface, status_info)
@interface = interface
@status_info = status_info
initialize_services!
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
11
12
13
|
# File 'lib/mios/device.rb', line 11
def method_missing(method, *args)
attributes[method.to_s] || super
end
|
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
3
4
5
|
# File 'lib/mios/device.rb', line 3
def category
@category
end
|
#interface ⇒ Object
Returns the value of attribute interface.
3
4
5
|
# File 'lib/mios/device.rb', line 3
def interface
@interface
end
|
Instance Method Details
#attributes ⇒ Object
20
21
22
23
24
|
# File 'lib/mios/device.rb', line 20
def attributes
@attributes ||= @status_info.select do |key, val|
!val.kind_of?(Hash) && !val.kind_of?(Array)
end
end
|
#reload ⇒ Object
15
16
17
18
|
# File 'lib/mios/device.rb', line 15
def reload
@status_info = @interface.device_status(id)
self
end
|
#room ⇒ Object
34
35
36
|
# File 'lib/mios/device.rb', line 34
def room
@room ||= @interface.rooms.find { |r| r.id == attributes['room'].to_i }
end
|
#states ⇒ Object
26
27
28
|
# File 'lib/mios/device.rb', line 26
def states
@status_info['states']
end
|