Class: EasyUpnp::UpnpDevice
- Inherits:
-
Object
- Object
- EasyUpnp::UpnpDevice
- Defined in:
- lib/easy_upnp/upnp_device.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Class Method Summary collapse
Instance Method Summary collapse
- #all_services ⇒ Object
- #device_name ⇒ Object
- #has_service?(urn) ⇒ Boolean
-
#initialize(uuid, service_definitions) ⇒ UpnpDevice
constructor
A new instance of UpnpDevice.
- #service(urn, options = {}, &block) ⇒ Object
- #service_definition(urn) ⇒ Object
Constructor Details
#initialize(uuid, service_definitions) ⇒ UpnpDevice
Returns a new instance of UpnpDevice.
12 13 14 15 |
# File 'lib/easy_upnp/upnp_device.rb', line 12 def initialize(uuid, service_definitions) @uuid = uuid @service_definitions = service_definitions end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
10 11 12 |
# File 'lib/easy_upnp/upnp_device.rb', line 10 def host @host end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
10 11 12 |
# File 'lib/easy_upnp/upnp_device.rb', line 10 def uuid @uuid end |
Class Method Details
.from_ssdp_messages(uuid, messages) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/easy_upnp/upnp_device.rb', line 17 def self.(uuid, ) service_definitions = . # Filter out messages that aren't service definitions. These include # the root device and the root UUID reject { || not [:st].include? ':service:' }. # Distinct by ST header -- might have repeats if we sent multiple # M-SEARCH packets group_by { || [:st] }. map { |_, | .first }. map do || { :location => [:location], :st => [:st] } end UpnpDevice.new(uuid, service_definitions) end |
Instance Method Details
#all_services ⇒ Object
44 45 46 |
# File 'lib/easy_upnp/upnp_device.rb', line 44 def all_services @service_definitions.map { |x| x[:st] } end |
#device_name ⇒ Object
40 41 42 |
# File 'lib/easy_upnp/upnp_device.rb', line 40 def device_name @device_name ||= fetch_device_name end |
#has_service?(urn) ⇒ Boolean
48 49 50 |
# File 'lib/easy_upnp/upnp_device.rb', line 48 def has_service?(urn) !service_definition(urn).nil? end |
#service(urn, options = {}, &block) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/easy_upnp/upnp_device.rb', line 52 def service(urn, = {}, &block) definition = service_definition(urn) if !definition.nil? DeviceControlPoint.from_service_definition(definition, , &block) end end |
#service_definition(urn) ⇒ Object
60 61 62 63 64 |
# File 'lib/easy_upnp/upnp_device.rb', line 60 def service_definition(urn) @service_definitions. reject { |s| s[:st] != urn }. first end |