Class: RRs::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/rrs/resource.rb

Direct Known Subclasses

IN::A, OPT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ttlObject (readonly)

Remaining Time To Live for this Resource.



5
6
7
# File 'lib/rrs/resource.rb', line 5

def ttl
  @ttl
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc:

Raises:

  • (NotImplementedError)


11
12
13
# File 'lib/rrs/resource.rb', line 11

def self.decode_rdata(msg) # :nodoc:
  raise NotImplementedError.new
end

.get_class(type_value, class_value) ⇒ Object

:nodoc:



42
43
44
45
46
47
48
49
# File 'lib/rrs/resource.rb', line 42

def self.get_class(type_value, class_value) # :nodoc:    
  path = []
  if class_value
   path.push(::RRs::Maps::QCLASS_MAP[class_value.to_i].to_s) if ::RRs::Maps::QCLASS_MAP[class_value.to_i]
  end
  path.push(::RRs::Maps::QTYPE_MAP[type_value.to_i].to_s)
  RRs.const_get(path.join("::"))
end

Instance Method Details

#==(other) ⇒ Object

:nodoc:



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rrs/resource.rb', line 15

def ==(other) # :nodoc:
  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

#encode_rdata(msg) ⇒ Object

:nodoc:

Raises:

  • (NotImplementedError)


7
8
9
# File 'lib/rrs/resource.rb', line 7

def encode_rdata(msg) # :nodoc:
  raise NotImplementedError.new
end

#eql?(other) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


28
29
30
# File 'lib/rrs/resource.rb', line 28

def eql?(other) # :nodoc:
  return self == other
end

#hashObject

:nodoc:



32
33
34
35
36
37
38
39
40
# File 'lib/rrs/resource.rb', line 32

def hash # :nodoc:
  h = 0
  vars = self.instance_variables
  vars.delete :@ttl
  vars.each {|name|
    h ^= self.instance_variable_get(name).hash
  }
  return h
end