Class: UPnP::SSDP::Search

Inherits:
Advertisement show all
Defined in:
lib/UPnP/SSDP.rb

Overview

Holds information about an M-SEARCH

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Advertisement

#expired?

Constructor Details

#initialize(date, target, wait_time) ⇒ Search

Creates a new Search



300
301
302
303
304
# File 'lib/UPnP/SSDP.rb', line 300

def initialize(date, target, wait_time)
  @date = date
  @target = target
  @wait_time = wait_time
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



278
279
280
# File 'lib/UPnP/SSDP.rb', line 278

def date
  @date
end

#targetObject (readonly)

Returns the value of attribute target.



280
281
282
# File 'lib/UPnP/SSDP.rb', line 280

def target
  @target
end

#wait_timeObject (readonly)

Returns the value of attribute wait_time.



282
283
284
# File 'lib/UPnP/SSDP.rb', line 282

def wait_time
  @wait_time
end

Class Method Details

.parse(response) ⇒ Object

Creates a new Search by parsing the text in response



287
288
289
290
291
292
293
294
295
# File 'lib/UPnP/SSDP.rb', line 287

def self.parse(response)
  response =~ /^mx:\s*(\d+)/i
  wait_time = Integer $1

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

  new Time.now, target, wait_time
end

Instance Method Details

#expirationObject

Expiration time of this advertisement



309
310
311
# File 'lib/UPnP/SSDP.rb', line 309

def expiration
  date + wait_time
end

#inspectObject

A friendlier inspect



316
317
318
# File 'lib/UPnP/SSDP.rb', line 316

def inspect
  "#<#{self.class}:0x#{object_id.to_s 16} #{target}>"
end