class WemoDevice::SSDP::Response

Public Class Methods

new(host, port, payload) click to toggle source
# File lib/wemo_device/ssdp.rb, line 11
def initialize(host, port, payload)
  @host = host
  @port = port
  @payload = payload
end

Public Instance Methods

location() click to toggle source
# File lib/wemo_device/ssdp.rb, line 25
def location
  http_response["location"]
end
search_target() click to toggle source
# File lib/wemo_device/ssdp.rb, line 17
def search_target
  http_response["st"]
end
unique_service_name() click to toggle source
# File lib/wemo_device/ssdp.rb, line 21
def unique_service_name
  http_response["usn"]
end

Private Instance Methods

http_response() click to toggle source
# File lib/wemo_device/ssdp.rb, line 31
def http_response
  @http_response ||= parse_http_response
end
parse_http_response() click to toggle source
# File lib/wemo_device/ssdp.rb, line 35
def parse_http_response
  # Using Net::HTTPResponse private API to parse HTTP body from String.
  # See `net/http.rb`, `net/protocol.rb`, and `net/http/response.rb`.
  string_io = StringIO.new(@payload)
  buffered_io = Net::BufferedIO.new(string_io)
  Net::HTTPResponse.read_new(buffered_io)
end