Class: UPnP::SSDP::Response
- Inherits:
-
Advertisement
- Object
- Advertisement
- UPnP::SSDP::Response
- Defined in:
- lib/UPnP/SSDP.rb
Overview
Holds information about a M-SEARCH response
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Date response was created or received.
-
#ext ⇒ Object
readonly
true if MAN header was understood.
-
#location ⇒ Object
readonly
URI where this device or service is described.
-
#max_age ⇒ Object
readonly
Maximum age this advertisement is valid for.
-
#name ⇒ Object
readonly
Unique Service Name.
-
#server ⇒ Object
readonly
Server version string.
-
#target ⇒ Object
readonly
Search target.
Class Method Summary collapse
-
.parse(response) ⇒ Object
Creates a new Response by parsing the text in
response
.
Instance Method Summary collapse
-
#initialize(date, max_age, location, server, target, name, ext) ⇒ Response
constructor
Creates a new Response.
-
#inspect ⇒ Object
A friendlier inspect.
Methods inherited from Advertisement
Constructor Details
#initialize(date, max_age, location, server, target, name, ext) ⇒ Response
Creates a new Response
254 255 256 257 258 259 260 261 262 |
# File 'lib/UPnP/SSDP.rb', line 254 def initialize(date, max_age, location, server, target, name, ext) @date = date @max_age = max_age @location = location @server = server @target = target @name = name @ext = ext end |
Instance Attribute Details
#date ⇒ Object (readonly)
Date response was created or received
192 193 194 |
# File 'lib/UPnP/SSDP.rb', line 192 def date @date end |
#ext ⇒ Object (readonly)
true if MAN header was understood
197 198 199 |
# File 'lib/UPnP/SSDP.rb', line 197 def ext @ext end |
#location ⇒ Object (readonly)
URI where this device or service is described
202 203 204 |
# File 'lib/UPnP/SSDP.rb', line 202 def location @location end |
#max_age ⇒ Object (readonly)
Maximum age this advertisement is valid for
207 208 209 |
# File 'lib/UPnP/SSDP.rb', line 207 def max_age @max_age end |
#name ⇒ Object (readonly)
Unique Service Name
212 213 214 |
# File 'lib/UPnP/SSDP.rb', line 212 def name @name end |
#server ⇒ Object (readonly)
Server version string
217 218 219 |
# File 'lib/UPnP/SSDP.rb', line 217 def server @server end |
#target ⇒ Object (readonly)
Search target
222 223 224 |
# File 'lib/UPnP/SSDP.rb', line 222 def target @target end |
Class Method Details
.parse(response) ⇒ Object
Creates a new Response by parsing the text in response
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/UPnP/SSDP.rb', line 227 def self.parse(response) response =~ /^cache-control:\s*max-age\s*=\s*(\d+)/i max_age = Integer $1 response =~ /^date:\s*(.*)/i date = $1 ? Time.parse($1) : Time.now ext = !!(response =~ /^ext:/i) response =~ /^location:\s*(\S*)/i location = URI.parse $1.strip response =~ /^server:\s*(.*)/i server = $1.strip response =~ /^st:\s*(\S*)/i target = $1.strip response =~ /^usn:\s*(\S*)/i name = $1.strip new date, max_age, location, server, target, name, ext end |
Instance Method Details
#inspect ⇒ Object
A friendlier inspect
267 268 269 |
# File 'lib/UPnP/SSDP.rb', line 267 def inspect "#<#{self.class}:0x#{object_id.to_s 16} #{target} #{location}>" end |