class UPnP::SSDP::Response

Holds information about a M-SEARCH response

Attributes

date[R]

Date response was created or received

ext[R]

true if MAN header was understood

location[R]

URI where this device or service is described

max_age[R]

Maximum age this advertisement is valid for

name[R]

Unique Service Name

server[R]

Server version string

target[R]

Search target

Public Class Methods

new(date, max_age, location, server, target, name, ext) click to toggle source

Creates a new Response

# 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
parse(response) click to toggle source

Creates a new Response by parsing the text in response

# File lib/UPnP/SSDP.rb, line 227
def self.parse(response)
  response =~ %r^cache-control:\s*max-age\s*=\s*(\d+)/
  max_age = Integer $1

  response =~ %r^date:\s*(.*)/
  date = $1 ? Time.parse($1) : Time.now

  ext = !!(response =~ %r^ext:/)

  response =~ %r^location:\s*(\S*)/
  location = URI.parse $1.strip

  response =~ %r^server:\s*(.*)/
  server = $1.strip

  response =~ %r^st:\s*(\S*)/
  target = $1.strip

  response =~ %r^usn:\s*(\S*)/
  name = $1.strip

  new date, max_age, location, server, target, name, ext
end

Public Instance Methods

inspect() click to toggle source

A friendlier inspect

# File lib/UPnP/SSDP.rb, line 267
def inspect
  "#<#{self.class}:0x#{object_id.to_s 16} #{target} #{location}>"
end