class Net::DNS::RR::MX
Mail Exchange Record (MX)¶ ↑
Class for DNS MX resource records.
A MX record specifies the name and relative preference of mail servers (mail exchangers in the DNS jargon) for the zone. The MX RR is used by SMTP (Mail) Agents to route mail for the domain.
Public Instance Methods
exchange()
click to toggle source
Gets the exchange value.
Returns a String.
# File lib/net/dns/rr/mx.rb, line 26 def exchange @exchange end
preference()
click to toggle source
Gets the preference value.
Returns an Integer.
# File lib/net/dns/rr/mx.rb, line 19 def preference @preference end
value()
click to toggle source
Gets the standardized value for this record, represented by the value of
preference
and exchange
.
Returns a String.
# File lib/net/dns/rr/mx.rb, line 34 def value "#{preference} #{exchange}" end
Private Instance Methods
build_pack()
click to toggle source
# File lib/net/dns/rr/mx.rb, line 79 def build_pack @mx_pack = [@preference].pack("n") + pack_name(@exchange) @rdlength = @mx_pack.size end
check_mx(input)
click to toggle source
# File lib/net/dns/rr/mx.rb, line 71 def check_mx(input) str = input.to_s unless str.strip =~ /^(\d+)\s+(\S+)$/ raise ArgumentError, "Invalid MX section `#{str}'" end [$1.to_i, $2] end
get_data()
click to toggle source
# File lib/net/dns/rr/mx.rb, line 84 def get_data @mx_pack end
get_inspect()
click to toggle source
# File lib/net/dns/rr/mx.rb, line 66 def get_inspect value end
set_type()
click to toggle source
# File lib/net/dns/rr/mx.rb, line 62 def set_type @type = Net::DNS::RR::Types.new("MX") end
subclass_new_from_binary(data, offset)
click to toggle source
# File lib/net/dns/rr/mx.rb, line 54 def subclass_new_from_binary(data, offset) @preference = data.unpack("@#{offset} n")[0] offset += 2 @exchange, offset = dn_expand(data, offset) offset end
subclass_new_from_hash(options)
click to toggle source
# File lib/net/dns/rr/mx.rb, line 41 def subclass_new_from_hash(options) if options.has_key?(:preference) && options.has_key?(:exchange) @preference = options[:preference].to_i @exchange = options[:exchange] else raise ArgumentError, ":preference and :exchange fields are mandatory" end end
subclass_new_from_string(str)
click to toggle source
# File lib/net/dns/rr/mx.rb, line 50 def subclass_new_from_string(str) @preference, @exchange = check_mx(str) end