Class: Druzy::Upnp::UpnpDevice
- Inherits:
-
Object
- Object
- Druzy::Upnp::UpnpDevice
- Defined in:
- lib/druzy/upnp/upnp_device.rb
Instance Attribute Summary collapse
-
#device_list ⇒ Object
readonly
Returns the value of attribute device_list.
-
#device_type ⇒ Object
readonly
Returns the value of attribute device_type.
-
#friendly_name ⇒ Object
readonly
Returns the value of attribute friendly_name.
-
#icon_list ⇒ Object
readonly
Returns the value of attribute icon_list.
-
#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.
-
#serial_number ⇒ Object
readonly
Returns the value of attribute serial_number.
-
#service_list ⇒ Object
readonly
Returns the value of attribute service_list.
-
#udn ⇒ Object
readonly
Returns the value of attribute udn.
-
#upc ⇒ Object
readonly
Returns the value of attribute upc.
-
#url_base ⇒ Object
readonly
Returns the value of attribute url_base.
Instance Method Summary collapse
-
#initialize(args) ⇒ UpnpDevice
constructor
A new instance of UpnpDevice.
Constructor Details
#initialize(args) ⇒ UpnpDevice
Returns a new instance of UpnpDevice.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/druzy/upnp/upnp_device.rb', line 15 def initialize(args) if args[:ssdp_message] != nil mess = args[:ssdp_message] location=mess.split("\n").reject{|line| line==nil || line["LOCATION"]==nil}.first initialize(:location => location[location.index(" ")+1..location.size-2]) elsif args[:location] != nil uri = URI(args[:location]) xml=Net::HTTP.get(uri) xml_nok = Nokogiri::XML(xml) xml_nok.remove_namespaces! initialize(:uri => uri, :xml => Nokogiri::XML(xml_nok.xpath('root/device').to_s)) else uri = args[:uri] xml_nok = args[:xml] @url_base = uri.scheme+'://'+uri.host+":"+uri.port.to_s @device_type = xml_nok.xpath('device/deviceType').text @friendly_name = xml_nok.xpath('device/friendlyName').text @manufacturer = xml_nok.xpath('device/manufacturer').text @manufacturer_url = xml_nok.xpath('device/manufacturerURL').text @model_description = xml_nok.xpath('device/modelDescription').text @model_name = xml_nok.xpath('device/modelName').text @model_number = xml_nok.xpath('device/modelNumber').text @model_url = xml_nok.xpath('device/modelURL').text @serial_number = xml_nok.xpath('device/serialNumber').text @udn = xml_nok.xpath('device/UDN').text @upc = xml_nok.xpath('device/UPC').text @icon_list = xml_nok.xpath('device/iconList/icon/url').to_a.collect{|el| @url_base+el.text} @service_list = xml_nok.xpath('device/serviceList/service').to_a.collect{|el| UpnpService.new( :service_type => el.xpath("serviceType").text, :service_id => el.xpath("serviceId").text, :location => @url_base+el.xpath("SCPDURL").text, :control_url => @url_base+el.xpath("controlURL").text, :event_sub_url => @url_base+el.xpath("eventSubURL").text )} @service_list.each do |service| method_name = service.service_id[service.service_id.rindex(':')+1..-1] define_singleton_method(method_name.to_sym) do return service end end @device_list = xml_nok.xpath('device/deviceList/device').to_a.collect{|el| UpnpDevice.new( :uri => uri, :xml => Nokogiri::XML(el.to_s) )} end end |
Instance Attribute Details
#device_list ⇒ Object (readonly)
Returns the value of attribute device_list.
13 14 15 |
# File 'lib/druzy/upnp/upnp_device.rb', line 13 def device_list @device_list end |
#device_type ⇒ Object (readonly)
Returns the value of attribute device_type.
11 12 13 |
# File 'lib/druzy/upnp/upnp_device.rb', line 11 def device_type @device_type end |
#friendly_name ⇒ Object (readonly)
Returns the value of attribute friendly_name.
11 12 13 |
# File 'lib/druzy/upnp/upnp_device.rb', line 11 def friendly_name @friendly_name end |
#icon_list ⇒ Object (readonly)
Returns the value of attribute icon_list.
12 13 14 |
# File 'lib/druzy/upnp/upnp_device.rb', line 12 def icon_list @icon_list end |
#manufacturer ⇒ Object (readonly)
Returns the value of attribute manufacturer.
11 12 13 |
# File 'lib/druzy/upnp/upnp_device.rb', line 11 def manufacturer @manufacturer end |
#manufacturer_url ⇒ Object (readonly)
Returns the value of attribute manufacturer_url.
11 12 13 |
# File 'lib/druzy/upnp/upnp_device.rb', line 11 def manufacturer_url @manufacturer_url end |
#model_description ⇒ Object (readonly)
Returns the value of attribute model_description.
11 12 13 |
# File 'lib/druzy/upnp/upnp_device.rb', line 11 def model_description @model_description end |
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
12 13 14 |
# File 'lib/druzy/upnp/upnp_device.rb', line 12 def model_name @model_name end |
#model_number ⇒ Object (readonly)
Returns the value of attribute model_number.
12 13 14 |
# File 'lib/druzy/upnp/upnp_device.rb', line 12 def model_number @model_number end |
#model_url ⇒ Object (readonly)
Returns the value of attribute model_url.
12 13 14 |
# File 'lib/druzy/upnp/upnp_device.rb', line 12 def model_url @model_url end |
#serial_number ⇒ Object (readonly)
Returns the value of attribute serial_number.
12 13 14 |
# File 'lib/druzy/upnp/upnp_device.rb', line 12 def serial_number @serial_number end |
#service_list ⇒ Object (readonly)
Returns the value of attribute service_list.
12 13 14 |
# File 'lib/druzy/upnp/upnp_device.rb', line 12 def service_list @service_list end |
#udn ⇒ Object (readonly)
Returns the value of attribute udn.
12 13 14 |
# File 'lib/druzy/upnp/upnp_device.rb', line 12 def udn @udn end |
#upc ⇒ Object (readonly)
Returns the value of attribute upc.
12 13 14 |
# File 'lib/druzy/upnp/upnp_device.rb', line 12 def upc @upc end |
#url_base ⇒ Object (readonly)
Returns the value of attribute url_base.
11 12 13 |
# File 'lib/druzy/upnp/upnp_device.rb', line 11 def url_base @url_base end |