lib/net/dns/rr/mx.rb in net-dns-0.9.0 vs lib/net/dns/rr/mx.rb in net-dns-0.20.0
- old
+ new
@@ -30,23 +30,21 @@
end
private
def subclass_new_from_hash(options)
- if options.key?(:preference) && options.key?(:exchange)
- @preference = options[:preference].to_i
- @exchange = options[:exchange]
- else
- raise ArgumentError, ":preference and :exchange fields are mandatory"
- end
+ raise ArgumentError, ":preference and :exchange fields are mandatory" unless options.key?(:preference) && options.key?(:exchange)
+
+ @preference = options[:preference].to_i
+ @exchange = options[:exchange]
end
def subclass_new_from_string(str)
@preference, @exchange = check_mx(str)
end
def subclass_new_from_binary(data, offset)
- @preference = data.unpack("@#{offset} n")[0]
+ @preference = data.unpack1("@#{offset} n")
offset += 2
@exchange, offset = dn_expand(data, offset)
offset
end