Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/net/dns/rr/mx.rb
Views: 11784
# -*- coding: binary -*-1##2#3# Net::DNS::RR::MX4#5# $Id: MX.rb,v 1.8 2006/07/28 07:33:36 bluemonk Exp $6#7##8910module Net11module DNS12class RR1314#------------------------------------------------------------15# RR type MX16#------------------------------------------------------------17class MX < RR18attr_reader :preference, :exchange1920private2122def check_mx(str)23if str.strip =~ /^(\d+)\s+(\S+)$/24return $1.to_i,$225else26raise RRArgumentError, "MX section not valid"27end28end2930def build_pack31@mx_pack = [@preference].pack("n") + pack_name(@exchange)32@rdlength = @mx_pack.size33end3435def set_type36@type = Net::DNS::RR::Types.new("MX")37end3839def get_data40@mx_pack41end4243def get_inspect44"#@preference #@exchange"45end4647def subclass_new_from_hash(args)48if args.has_key? :preference and args.has_key? :exchange49@preference = args[0][:preference].to_i50@exchange = args[0][:exchange]51else52raise RRArgumentError, ":preference and :exchange fields are mandatory but missing"53end54end5556def subclass_new_from_string(str)57@preference,@exchange = check_mx(str)58end5960def subclass_new_from_binary(data,offset)61@preference = data.unpack("@#{offset} n")[0]62offset += 263@exchange,offset = dn_expand(data,offset)64return offset65end6667end # class MX6869end # class RR70end # module DNS71end # module Net727374