123456789_123456789_123456789_123456789_123456789_

Class: Resolv::DNS::Resource::Generic

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Resource
Instance Chain:
self, Resource
Inherits: Resource
  • Object
Defined in: lib/resolv.rb

Overview

A generic resource abstract class.

Class Method Summary

Instance Attribute Summary

  • #data readonly

    Data for this generic resource.

Instance Method Summary

Constructor Details

.new(data) ⇒ Generic

Creates a new generic resource.

[ GitHub ]

  
# File 'lib/resolv.rb', line 2326

def initialize(data)
  @data = data
end

Class Method Details

.create(type_value, class_value)

[ GitHub ]

  
# File 'lib/resolv.rb', line 2358

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)

[ GitHub ]

  
# File 'lib/resolv.rb', line 2339

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.

[ GitHub ]

  
# File 'lib/resolv.rb', line 2345

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 Attribute Details

#data (readonly)

Data for this generic resource.

[ GitHub ]

  
# File 'lib/resolv.rb', line 2333

attr_reader :data

Instance Method Details

#==(other)

[ GitHub ]

  
# File 'lib/resolv.rb', line 2352

def ==(other) # :nodoc:
  return other.is_a?(Generic) &&
         Generic.type_class_equal?(self.class, other.class) &&
         @data == other.data
end

#encode_rdata(msg)

[ GitHub ]

  
# File 'lib/resolv.rb', line 2335

def encode_rdata(msg) # :nodoc:
  msg.put_bytes(data)
end