Method: Dnsruby::Types.typesbyname

Defined in:
lib/dnsruby.rb

.typesbyname(name) ⇒ Object

– typesbyval and typesbyname functions are wrappers around the similarly named hashes. They are used for ‘unknown’ DNS RR types (RFC3597)

typesbyname returns they TYPEcode as a function of the TYPE mnemonic. If the TYPE mapping is not specified the generic mnemonic TYPE### is returned.



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/dnsruby.rb', line 307

def Types.typesbyname(name)  #:nodoc: all
  name.upcase!
  
  if to_code(name)
    return to_code(name)
  end
  
  
  if ((name =~/^\s*TYPE(\d+)\s*$/o)==nil)
    raise ArgumentError, "Net::DNS::typesbyname() argument (#{name}) is not TYPE###"
  end
  
  val = $1.to_i
  if val > 0xffff
    raise ArgumentError, 'Net::DNS::typesbyname() argument larger than ' + 0xffff
  end
  
  return val;
end