Class: DNS::Type
- Inherits:
-
Object
- Object
- DNS::Type
- Defined in:
- lib/faildns/type.rb
Overview
– TYPE fields are used in resource records. Note that these types are a subset of QTYPEs.
TYPE value and meaning
A 1 a host address
NS 2 an authoritative name server
MD 3 a mail destination (Obsolete - use MX)
MF 4 a mail forwarder (Obsolete - use MX)
CNAME 5 the canonical name for an alias
SOA 6 marks the start of a zone of authority
MB 7 a mailbox domain name (EXPERIMENTAL)
MG 8 a mail group member (EXPERIMENTAL)
MR 9 a mail rename domain name (EXPERIMENTAL)
NULL 10 a null RR (EXPERIMENTAL)
WKS 11 a well known service description
PTR 12 a domain name pointer
HINFO 13 host information
MINFO 14 mailbox or mail list information
MX 15 mail exchange
TXT 16 text strings ++
Direct Known Subclasses
Constant Summary collapse
- Values =
{ 1 => :A, 2 => :NS, 3 => :MD, 4 => :MF, 5 => :CNAME, 6 => :SOA, 7 => :MB, 8 => :MG, 9 => :MR, 10 => :NULL, 11 => :WKS, 12 => :PTR, 13 => :HINFO, 14 => :MINFO, 15 => :MX, 16 => :TXT, 17 => :RP, 18 => :AFSDB, 19 => :X25, 20 => :ISDN, 21 => :RT, 22 => :NSAP, 23 => :NSAP_PTR, 24 => :SIG, 25 => :KEY, 26 => :PX, 27 => :GPOS, 28 => :AAAA, 29 => :LOC, 30 => :NXT, 31 => :EID, 32 => :NIMLOC, 33 => :SRV, 34 => :ATMA, 35 => :NAPTR, 36 => :KX, 37 => :CERT, 38 => :A6, 39 => :DNAME, 40 => :SINK, 41 => :OPT, 42 => :APL, 43 => :DS, 44 => :SSHFP, 45 => :IPSECKEY, 46 => :RRSIG, 47 => :NSEC, 48 => :DNSKEY, 49 => :DHCID, 50 => :NSEC3, 51 => :NSEC3PARAM, 55 => :HIP, 56 => :NINFO, 57 => :RKEY, 58 => :TALINK, 99 => :SPF, 100 => :UINFO, 101 => :UID, 102 => :GID, 103 => :UNSPEC, 249 => :TKEY, 250 => :TSIG, 251 => :IXFR, 32768 => :TA, 32769 => :DLV }
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(what) ⇒ Object
-
#initialize(value) ⇒ Type
constructor
A new instance of Type.
- #pack ⇒ Object
- #to_s ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(value) ⇒ Type
Returns a new instance of Type.
149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/faildns/type.rb', line 149 def initialize (value) if value.is_a? Symbol @value = Values.find {|key, val| val == value}.first rescue nil elsif value.is_a? Integer @value = value else @value = value.value rescue nil end if !self.to_sym raise ArgumentError.new('The passed value is not a suitable type.') end end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
147 148 149 |
# File 'lib/faildns/type.rb', line 147 def value @value end |
Class Method Details
.length(string = nil) ⇒ Object
143 144 145 |
# File 'lib/faildns/type.rb', line 143 def self.length (string=nil) 2 end |
.parse(string) ⇒ Object
134 135 136 137 138 139 140 141 |
# File 'lib/faildns/type.rb', line 134 def self.parse (string) string.force_encoding 'BINARY' result = self.new(string.unpack('n').first) string[0, self.length] = '' return result end |
Instance Method Details
#==(what) ⇒ Object
167 168 169 170 171 172 173 174 175 |
# File 'lib/faildns/type.rb', line 167 def == (what) if what.is_a? Symbol self.to_sym == what elsif value.is_a? Integer @value == what else @value == what.value rescue false end end |
#pack ⇒ Object
163 164 165 |
# File 'lib/faildns/type.rb', line 163 def pack [@value].pack('n') end |
#to_s ⇒ Object
181 182 183 |
# File 'lib/faildns/type.rb', line 181 def to_s Values[@value].to_s end |
#to_sym ⇒ Object
177 178 179 |
# File 'lib/faildns/type.rb', line 177 def to_sym Values[@value] end |