Class: DNS::Zone::RR::MX

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

Overview

`MX` resource record.

RFC 1035

Constant Summary collapse

REGEX_MX_RDATA =
%r{
  (?<priority>\d+)\s*
  (?<exchange>#{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

#exchangeObject

Returns the value of attribute exchange


12
13
14
# File 'lib/dns/zone/rr/mx.rb', line 12

def exchange
  @exchange
end

#priorityObject

Returns the value of attribute priority


11
12
13
# File 'lib/dns/zone/rr/mx.rb', line 11

def priority
  @priority
end

Instance Method Details

#dumpObject


14
15
16
17
18
19
# File 'lib/dns/zone/rr/mx.rb', line 14

def dump
  parts = general_prefix
  parts << priority
  parts << exchange
  parts.join(' ')
end

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


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dns/zone/rr/mx.rb', line 21

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

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

  @priority = captures[:priority].to_i
  @exchange = captures[:exchange]
  self
end