Class: DNS::Zone::RR::SRV

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

Overview

`SRV` resource record.

RFC 2782

Constant Summary collapse

REGEX_SRV_RDATA =
%r{
  (?<priority>\d+)\s*
  (?<weight>\d+)\s*
  (?<port>\d+)\s*
  (?<target>#{DNS::Zone::RR::REGEX_DOMAINNAME})\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

#portObject

Returns the value of attribute port


13
14
15
# File 'lib/dns/zone/rr/srv.rb', line 13

def port
  @port
end

#priorityObject

Returns the value of attribute priority


13
14
15
# File 'lib/dns/zone/rr/srv.rb', line 13

def priority
  @priority
end

#targetObject

Returns the value of attribute target


13
14
15
# File 'lib/dns/zone/rr/srv.rb', line 13

def target
  @target
end

#weightObject

Returns the value of attribute weight


13
14
15
# File 'lib/dns/zone/rr/srv.rb', line 13

def weight
  @weight
end

Instance Method Details

#dumpObject


15
16
17
18
19
20
21
22
# File 'lib/dns/zone/rr/srv.rb', line 15

def dump
  parts = general_prefix
  parts << priority
  parts << weight
  parts << port
  parts << target
  parts.join(' ')
end

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


24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dns/zone/rr/srv.rb', line 24

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

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

  @priority = captures[:priority].to_i
  @weight = captures[:weight].to_i
  @port = captures[:port].to_i
  @target = captures[:target]
  self
end