Class: SimpleUpnp::Device
- Inherits:
-
Object
- Object
- SimpleUpnp::Device
- Defined in:
- lib/simple_upnp/device.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#st ⇒ Object
readonly
Returns the value of attribute st.
-
#usn ⇒ Object
readonly
Returns the value of attribute usn.
Instance Method Summary collapse
-
#initialize(message) ⇒ Device
constructor
A new instance of Device.
- #to_json(include_location_details = false) ⇒ Object
Constructor Details
#initialize(message) ⇒ Device
Returns a new instance of Device.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/simple_upnp/device.rb', line 8 def initialize() lines = .split(/\r?\n/) lines.each do |line| if line =~ /^ST:/i @st = parse_token(line.split(': ')) elsif line =~ /^SERVER:/i @server = parse_token(line.split(': ')) elsif line =~ /^USN:/i @usn = parse_token(line.split(': ')) # Trim off data after :: # For example, we don't want upnp:rootdevice from uuid:7DD8D98F-6577-582D-AF37-38B92EB830A4::upnp:rootdevice @usn = @usn.split('::').first elsif line =~ /^LOCATION:/i @location = parse_token(line.split(': ')) end end end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
6 7 8 |
# File 'lib/simple_upnp/device.rb', line 6 def location @location end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
6 7 8 |
# File 'lib/simple_upnp/device.rb', line 6 def server @server end |
#st ⇒ Object (readonly)
Returns the value of attribute st.
6 7 8 |
# File 'lib/simple_upnp/device.rb', line 6 def st @st end |
#usn ⇒ Object (readonly)
Returns the value of attribute usn.
6 7 8 |
# File 'lib/simple_upnp/device.rb', line 6 def usn @usn end |
Instance Method Details
#to_json(include_location_details = false) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/simple_upnp/device.rb', line 26 def to_json(include_location_details = false) h = { :st => st, :server => server, :usn => usn, :location => location } h.merge!(retrieve_location_details) if include_location_details and location h end |