Class: Dnsruby::Classes
- Inherits:
-
CodeMapper
- Object
- CodeMapper
- Dnsruby::Classes
- Defined in:
- lib/dnsruby.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
Class Method Summary collapse
-
.classesbyname(name) ⇒ Object
classesbyval and classesbyname functions are wrappers around the similarly named hashes.
-
.classesbyval(val) ⇒ Object
:nodoc: all.
Instance Method Summary collapse
Methods inherited from CodeMapper
#<=>, #==, add_pair, #hash, #initialize, #inspect, maxcode, method_missing, regexp, #set_code, #set_string, strings, to_code, to_string, update
Constructor Details
This class inherits a constructor from Dnsruby::CodeMapper
Class Method Details
.classesbyname(name) ⇒ Object
classesbyval and classesbyname functions are wrappers around the similarly named hashes. They are used for ‘unknown’ DNS RR classess (RFC3597)
See typesbyval and typesbyname, these beasts have the same functionality
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/dnsruby.rb', line 188 def Classes.classesbyname(name) #:nodoc: all name.upcase!; if to_code(name) return to_code(name) end if ((name =~/^\s*CLASS(\d+)\s*$/o) == nil) raise ArgumentError, "classesbyval() argument is not CLASS### (#{name})" end val = $1.to_i if val > 0xffff raise ArgumentError, 'classesbyval() argument larger than ' + 0xffff end return val; end |
.classesbyval(val) ⇒ Object
:nodoc: all
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/dnsruby.rb', line 208 def Classes.classesbyval(val) #:nodoc: all if (val.class == String) if ((val =~ /^\s*0*([0-9]+)\s*$/) == nil) raise ArgumentError, "classesbybal() argument is not numeric (#{val})" # unless val.gsub!("^\s*0*([0-9]+)\s*$", "$1") # val =~ s/^\s*0*([0-9]+)\s*$/$1/o;# end val = $1.to_i end return to_string(val) if to_string(val) raise ArgumentError, 'classesbyval() argument larger than ' + 0xffff if val > 0xffff; return "CLASS#{val}"; end |
Instance Method Details
#unknown_code(arg) ⇒ Object
179 180 181 182 |
# File 'lib/dnsruby.rb', line 179 def unknown_code(arg) Classes.add_pair('CLASS' + arg.to_s, arg) set_code(arg) end |
#unknown_string(arg) ⇒ Object
170 171 172 173 174 175 176 177 |
# File 'lib/dnsruby.rb', line 170 def unknown_string(arg) if (arg=~/^CLASS/i) Classes.add_pair(arg, arg.gsub('CLASS', '').to_i) set_string(arg) else raise ArgumentError.new("String #{arg} not a member of #{self.class}") end end |