mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/resolv.rb (Resolv::DNS::Resource#ttl): new attribute.
(Resolv::DNS::Resource#==): ignore @ttl. (Resolv::DNS::Resource#hash): ditto. (Resolv::DNS::Message::MessageDecoder#get_rr): save TTL in a Resource object. based on [ruby-core:5190] by Eric Hodel. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
27e59d7cdd
commit
e710ced659
2 changed files with 31 additions and 7 deletions
|
@ -1,3 +1,12 @@
|
|||
Thu Jun 16 00:13:41 2005 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* lib/resolv.rb (Resolv::DNS::Resource#ttl): new attribute.
|
||||
(Resolv::DNS::Resource#==): ignore @ttl.
|
||||
(Resolv::DNS::Resource#hash): ditto.
|
||||
(Resolv::DNS::Message::MessageDecoder#get_rr): save TTL in a
|
||||
Resource object.
|
||||
based on [ruby-core:5190] by Eric Hodel.
|
||||
|
||||
Wed Jun 15 18:26:39 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/lib/tk.rb: support "tk inactive" sub-command [for Tcl/Tk8.5a3]
|
||||
|
|
|
@ -1406,7 +1406,9 @@ class Resolv
|
|||
name = self.get_name
|
||||
type, klass, ttl = self.get_unpack('nnN')
|
||||
typeclass = Resource.get_class(type, klass)
|
||||
return name, ttl, self.get_length16 {typeclass.decode_rdata(self)}
|
||||
res = self.get_length16 { typeclass.decode_rdata self }
|
||||
res.instance_variable_set :@ttl, ttl
|
||||
return name, ttl, res
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1429,6 +1431,11 @@ class Resolv
|
|||
|
||||
class Resource < Query
|
||||
|
||||
##
|
||||
# Remaining Time To Live for this Resource.
|
||||
|
||||
attr_reader :ttl
|
||||
|
||||
ClassHash = {} # :nodoc:
|
||||
|
||||
def encode_rdata(msg) # :nodoc:
|
||||
|
@ -1440,10 +1447,16 @@ class Resolv
|
|||
end
|
||||
|
||||
def ==(other) # :nodoc:
|
||||
return self.class == other.class &&
|
||||
self.instance_variables == other.instance_variables &&
|
||||
self.instance_variables.collect {|name| self.instance_eval name} ==
|
||||
other.instance_variables.collect {|name| other.instance_eval name}
|
||||
return false unless self.class == other.class
|
||||
s_ivars = self.instance_variables
|
||||
s_ivars.sort!
|
||||
s_ivars.delete "@ttl"
|
||||
o_ivars = other.instance_variables
|
||||
o_ivars.sort!
|
||||
o_ivars.delete "@ttl"
|
||||
return s_ivars == o_ivars &&
|
||||
s_ivars.collect {|name| self.instance_variable_get name} ==
|
||||
o_ivars.collect {|name| other.instance_variable_get name}
|
||||
end
|
||||
|
||||
def eql?(other) # :nodoc:
|
||||
|
@ -1452,8 +1465,10 @@ class Resolv
|
|||
|
||||
def hash # :nodoc:
|
||||
h = 0
|
||||
self.instance_variables.each {|name|
|
||||
h ^= self.instance_eval("#{name}.hash")
|
||||
vars = self.instance_variables
|
||||
vars.delete "@ttl"
|
||||
vars.each {|name|
|
||||
h ^= self.instance_variable_get(name).hash
|
||||
}
|
||||
return h
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue