Class: Sinatra::Hue::Device
- Inherits:
-
Object
- Object
- Sinatra::Hue::Device
- Defined in:
- lib/alexa_hue/hue_switch.rb
Overview
The Device and SSDP classes are basically lifted from Sam Soffes’ great GitHub repo: github.com/soffes/discover.
Instance Attribute Summary collapse
-
#description_url ⇒ Object
readonly
Returns the value of attribute description_url.
-
#hardware_version ⇒ Object
readonly
Returns the value of attribute hardware_version.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#manufacturer ⇒ Object
readonly
Returns the value of attribute manufacturer.
-
#manufacturer_url ⇒ Object
readonly
Returns the value of attribute manufacturer_url.
-
#model_description ⇒ Object
readonly
Returns the value of attribute model_description.
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
-
#model_number ⇒ Object
readonly
Returns the value of attribute model_number.
-
#model_url ⇒ Object
readonly
Returns the value of attribute model_url.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#serial_number ⇒ Object
readonly
Returns the value of attribute serial_number.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#service_type ⇒ Object
readonly
Returns the value of attribute service_type.
-
#software_version ⇒ Object
readonly
Returns the value of attribute software_version.
-
#url_base ⇒ Object
readonly
Returns the value of attribute url_base.
-
#usn ⇒ Object
readonly
Returns the value of attribute usn.
Instance Method Summary collapse
- #get_response ⇒ Object
-
#initialize(info) ⇒ Device
constructor
A new instance of Device.
Constructor Details
#initialize(info) ⇒ Device
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
# File 'lib/alexa_hue/hue_switch.rb', line 426 def initialize(info) headers = {} info[0].split("\r\n").each do |line| matches = line.match(/^([\w\-]+):(?:\s)*(.*)$/) next unless matches headers[matches[1].upcase] = matches[2] end @description_url = headers['LOCATION'] @server = headers['SERVER'] @service_type = headers['ST'] @usn = headers['USN'] info = info[1] @port = info[1] @ip = info[2] end |
Instance Attribute Details
#description_url ⇒ Object (readonly)
Returns the value of attribute description_url.
410 411 412 |
# File 'lib/alexa_hue/hue_switch.rb', line 410 def description_url @description_url end |
#hardware_version ⇒ Object (readonly)
Returns the value of attribute hardware_version.
424 425 426 |
# File 'lib/alexa_hue/hue_switch.rb', line 424 def hardware_version @hardware_version end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
408 409 410 |
# File 'lib/alexa_hue/hue_switch.rb', line 408 def ip @ip end |
#manufacturer ⇒ Object (readonly)
Returns the value of attribute manufacturer.
416 417 418 |
# File 'lib/alexa_hue/hue_switch.rb', line 416 def manufacturer @manufacturer end |
#manufacturer_url ⇒ Object (readonly)
Returns the value of attribute manufacturer_url.
417 418 419 |
# File 'lib/alexa_hue/hue_switch.rb', line 417 def manufacturer_url @manufacturer_url end |
#model_description ⇒ Object (readonly)
Returns the value of attribute model_description.
420 421 422 |
# File 'lib/alexa_hue/hue_switch.rb', line 420 def model_description @model_description end |
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
418 419 420 |
# File 'lib/alexa_hue/hue_switch.rb', line 418 def model_name @model_name end |
#model_number ⇒ Object (readonly)
Returns the value of attribute model_number.
419 420 421 |
# File 'lib/alexa_hue/hue_switch.rb', line 419 def model_number @model_number end |
#model_url ⇒ Object (readonly)
Returns the value of attribute model_url.
421 422 423 |
# File 'lib/alexa_hue/hue_switch.rb', line 421 def model_url @model_url end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
415 416 417 |
# File 'lib/alexa_hue/hue_switch.rb', line 415 def name @name end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
409 410 411 |
# File 'lib/alexa_hue/hue_switch.rb', line 409 def port @port end |
#serial_number ⇒ Object (readonly)
Returns the value of attribute serial_number.
422 423 424 |
# File 'lib/alexa_hue/hue_switch.rb', line 422 def serial_number @serial_number end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
411 412 413 |
# File 'lib/alexa_hue/hue_switch.rb', line 411 def server @server end |
#service_type ⇒ Object (readonly)
Returns the value of attribute service_type.
412 413 414 |
# File 'lib/alexa_hue/hue_switch.rb', line 412 def service_type @service_type end |
#software_version ⇒ Object (readonly)
Returns the value of attribute software_version.
423 424 425 |
# File 'lib/alexa_hue/hue_switch.rb', line 423 def software_version @software_version end |
#url_base ⇒ Object (readonly)
Returns the value of attribute url_base.
414 415 416 |
# File 'lib/alexa_hue/hue_switch.rb', line 414 def url_base @url_base end |
#usn ⇒ Object (readonly)
Returns the value of attribute usn.
413 414 415 |
# File 'lib/alexa_hue/hue_switch.rb', line 413 def usn @usn end |
Instance Method Details
#get_response ⇒ Object
444 445 446 |
# File 'lib/alexa_hue/hue_switch.rb', line 444 def get_response Net::HTTP.get_response(URI.parse(description_url)).body end |