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.
2264 2265 2266 |
# File 'lib/resolv.rb', line 2264 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Data for this generic resource.
2271 2272 2273 |
# File 'lib/resolv.rb', line 2271 def data @data end |
Class Method Details
.create(type_value, class_value) ⇒ Object
:nodoc:
2296 2297 2298 2299 2300 2301 2302 2303 2304 |
# File 'lib/resolv.rb', line 2296 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:
2277 2278 2279 |
# File 'lib/resolv.rb', line 2277 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.
2283 2284 2285 2286 2287 2288 |
# File 'lib/resolv.rb', line 2283 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:
2290 2291 2292 2293 2294 |
# File 'lib/resolv.rb', line 2290 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:
2273 2274 2275 |
# File 'lib/resolv.rb', line 2273 def encode_rdata(msg) # :nodoc: msg.put_bytes(data) end |