Class: DNS::Zone::RR::NAPTR

Inherits:
Record
  • Object
show all
Defined in:
lib/dns/zone/rr/naptr.rb

Overview

‘NAPTR` resource record.

RFC 3403

Constant Summary collapse

REGEX_NAPTR_RDATA =
%r{
  (?<order>\d+)\s*
  (?<pref>\d+)\s*
  (?<flags>#{DNS::Zone::RR::REGEX_CHARACTER_STRING})\s*
  (?<service>#{DNS::Zone::RR::REGEX_CHARACTER_STRING})\s*
  (?<regexp>#{DNS::Zone::RR::REGEX_CHARACTER_STRING})\s*
  (?<replacement>#{DNS::Zone::RR::REGEX_DOMAINNAME}|\.{1})\s*
}mx

Instance Attribute Summary collapse

Attributes inherited from Record

#klass, #label, #ttl

Instance Method Summary collapse

Methods inherited from Record

#general_prefix, #initialize, #load_general_and_get_rdata, #type

Constructor Details

This class inherits a constructor from DNS::Zone::RR::Record

Instance Attribute Details

#flagsObject

Returns the value of attribute flags.



15
16
17
# File 'lib/dns/zone/rr/naptr.rb', line 15

def flags
  @flags
end

#orderObject

Returns the value of attribute order.



15
16
17
# File 'lib/dns/zone/rr/naptr.rb', line 15

def order
  @order
end

#prefObject

Returns the value of attribute pref.



15
16
17
# File 'lib/dns/zone/rr/naptr.rb', line 15

def pref
  @pref
end

#regexpObject

Returns the value of attribute regexp.



15
16
17
# File 'lib/dns/zone/rr/naptr.rb', line 15

def regexp
  @regexp
end

#replacementObject

Returns the value of attribute replacement.



15
16
17
# File 'lib/dns/zone/rr/naptr.rb', line 15

def replacement
  @replacement
end

#serviceObject

Returns the value of attribute service.



15
16
17
# File 'lib/dns/zone/rr/naptr.rb', line 15

def service
  @service
end

Instance Method Details

#dumpObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/dns/zone/rr/naptr.rb', line 17

def dump
  parts = general_prefix
  parts << order
  parts << pref
  parts << %Q{"#{flags}"}
  parts << %Q{"#{service}"}
  parts << %Q{"#{regexp}"}
  parts << replacement
  parts.join(' ')
end

#load(string, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dns/zone/rr/naptr.rb', line 28

def load(string, options = {})
  rdata = load_general_and_get_rdata(string, options)
  return nil unless rdata

  captures = rdata.match(REGEX_NAPTR_RDATA)
  return nil unless captures

  @order = captures[:order].to_i
  @pref = captures[:pref].to_i
  @flags = captures[:flags].scan(/#{DNS::Zone::RR::REGEX_CHARACTER_STRING}/).join
  @service = captures[:service].scan(/#{DNS::Zone::RR::REGEX_CHARACTER_STRING}/).join
  @regexp = captures[:regexp].scan(/#{DNS::Zone::RR::REGEX_CHARACTER_STRING}/).join
  @replacement = captures[:replacement]
  self
end