Class: Net::DNS::MDNS::Question
- Inherits:
-
Object
- Object
- Net::DNS::MDNS::Question
- Defined in:
- lib/net/dns/mdns.rb
Constant Summary collapse
- RETRIES =
Normally we see our own question, so an update will occur right away, causing retries to be set to 1. If we don’t see our own question, for some reason, we’ll ask again a second later.
[1, 1, 2, 4]
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#retries ⇒ Object
Returns the value of attribute retries.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, type) ⇒ Question
constructor
A new instance of Question.
-
#refresh ⇒ Object
Questions are asked 4 times, repeating at increasing intervals of 1, 2, and 4 seconds.
- #to_s ⇒ Object
-
#update ⇒ Object
Update the number of times the question has been asked based on having seen the question, so that the question is considered asked whether we asked it, or another machine/process asked.
Constructor Details
#initialize(name, type) ⇒ Question
Returns a new instance of Question.
278 279 280 281 282 283 284 285 |
# File 'lib/net/dns/mdns.rb', line 278 def initialize(name, type) @name = name @type = type @lastq = Time.now.to_i @retries = 0 end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
270 271 272 |
# File 'lib/net/dns/mdns.rb', line 270 def name @name end |
#retries ⇒ Object
Returns the value of attribute retries.
270 271 272 |
# File 'lib/net/dns/mdns.rb', line 270 def retries @retries end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
270 271 272 |
# File 'lib/net/dns/mdns.rb', line 270 def type @type end |
Instance Method Details
#refresh ⇒ Object
Questions are asked 4 times, repeating at increasing intervals of 1, 2, and 4 seconds.
297 298 299 300 |
# File 'lib/net/dns/mdns.rb', line 297 def refresh r = RETRIES[retries] @lastq + r if r end |
#to_s ⇒ Object
302 303 304 |
# File 'lib/net/dns/mdns.rb', line 302 def to_s "#{@name.to_s}/#{DNS.rrname @type} (#{@retries})" end |
#update ⇒ Object
Update the number of times the question has been asked based on having seen the question, so that the question is considered asked whether we asked it, or another machine/process asked.
290 291 292 293 |
# File 'lib/net/dns/mdns.rb', line 290 def update @retries += 1 @lastq = Time.now.to_i end |