Class: Lono::Device
- Inherits:
-
Object
- Object
- Lono::Device
- Defined in:
- lib/lono-api/device.rb
Constant Summary collapse
- VALID_DEVICE_REGEX =
/[a-f0-9]{24}/
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#session_token ⇒ Object
readonly
Returns the value of attribute session_token.
Instance Method Summary collapse
-
#initialize(device_id, session_token) ⇒ Device
constructor
A new instance of Device.
- #set_zone(zone_id, action) ⇒ Object
Constructor Details
#initialize(device_id, session_token) ⇒ Device
Returns a new instance of Device.
7 8 9 10 11 |
# File 'lib/lono-api/device.rb', line 7 def initialize(device_id, session_token) @id = device_id @session_token = session_token validate! end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/lono-api/device.rb', line 5 def id @id end |
#session_token ⇒ Object (readonly)
Returns the value of attribute session_token.
5 6 7 |
# File 'lib/lono-api/device.rb', line 5 def session_token @session_token end |
Instance Method Details
#set_zone(zone_id, action) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/lono-api/device.rb', line 13 def set_zone(zone_id, action) query_device @id, { :url => "zones/#{zone_id}/#{action and "on" or "off"}", :method => "post" } end |