Class: Resolv::DNS::Resource::Generic
- Inherits:
-
Resource
- Object
- Resource
- Resolv::DNS::Resource::Generic
- Defined in:
- lib/resolv.rb
Overview
A generic resource abstract class.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Data for this generic resource.
Class Method Summary collapse
-
.create(type_value, class_value) ⇒ Object
:nodoc:.
-
.decode_rdata(msg) ⇒ Object
:nodoc:.
-
.type_class_equal?(klass, other) ⇒ Boolean
create makes a fresh class for each decoded resource, so the type and class values have to be compared instead of the class itself.
Instance Method Summary collapse
-
#==(other) ⇒ Object
:nodoc:.
-
#encode_rdata(msg) ⇒ Object
:nodoc:.
-
#initialize(data) ⇒ Generic
constructor
Creates a new generic resource.
Constructor Details
#initialize(data) ⇒ Generic
Creates a new generic resource.
2361 2362 2363 |
# File 'lib/resolv.rb', line 2361 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Data for this generic resource.
2368 2369 2370 |
# File 'lib/resolv.rb', line 2368 def data @data end |
Class Method Details
.create(type_value, class_value) ⇒ Object
:nodoc:
2393 2394 2395 2396 2397 2398 2399 2400 2401 |
# File 'lib/resolv.rb', line 2393 def self.create(type_value, class_value) # :nodoc: c = Class.new(Generic) c.const_set(:TypeValue, type_value) c.const_set(:ClassValue, class_value) # Not registered in a constant or in ClassHash. get_class creates a # class for every unknown (type, class) pair, so registering them # permanently would let a malicious response exhaust memory. return c end |
.decode_rdata(msg) ⇒ Object
:nodoc:
2374 2375 2376 |
# File 'lib/resolv.rb', line 2374 def self.decode_rdata(msg) # :nodoc: return self.new(msg.get_bytes) end |
.type_class_equal?(klass, other) ⇒ Boolean
create makes a fresh class for each decoded resource, so the type and class values have to be compared instead of the class itself.
2380 2381 2382 2383 2384 2385 |
# File 'lib/resolv.rb', line 2380 def self.type_class_equal?(klass, other) # :nodoc: return true if klass.equal?(other) Generic > klass && Generic > other && klass::TypeValue == other::TypeValue && klass::ClassValue == other::ClassValue end |
Instance Method Details
#==(other) ⇒ Object
:nodoc:
2387 2388 2389 2390 2391 |
# File 'lib/resolv.rb', line 2387 def ==(other) # :nodoc: return other.is_a?(Generic) && Generic.type_class_equal?(self.class, other.class) && @data == other.data end |
#encode_rdata(msg) ⇒ Object
:nodoc:
2370 2371 2372 |
# File 'lib/resolv.rb', line 2370 def encode_rdata(msg) # :nodoc: msg.put_bytes(data) end |