Class: Dnsruby::Classes

Inherits:
CodeMapper show all
Defined in:
lib/dnsruby/code_mappers.rb

Constant Summary collapse

IN =

RFC 1035

1
CH =

RFC 1035

3
HS =

CHAOS = 3 # RFC 1035

4
NONE =

HESIOD = 4 # RFC 1035

254
ANY =

RFC 2136

255

Instance Attribute Summary

Attributes inherited from CodeMapper

#code, #string

Instance Method Summary collapse

Methods inherited from CodeMapper

#<=>, #==, #hash, #initialize, #inspect, method_missing, regexp, #set_code, #set_string

Instance Method Details

#unknown_code(arg) ⇒ Object



93
94
95
96
97
# File 'lib/dnsruby/code_mappers.rb', line 93

def unknown_code(arg)
  RRCodeRange.check(arg)
  Classes.add_pair('CLASS' + arg.to_s, arg) unless Classes.to_string(arg)
  set_code(arg)
end

#unknown_string(arg) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/dnsruby/code_mappers.rb', line 81

def unknown_string(arg)
  if (match = /\ACLASS(\d+)\z/i.match(arg))
    # Store one name per code so case and leading-zero variants cannot
    # fill the global mapping table.
    unknown_code(match[1].to_i)
    # Keep the supplied spelling on this object without registering it.
    @string = arg.dup.freeze
  else
    raise ArgumentError.new("String #{arg} not a member of #{self.class}")
  end
end