Class: Nesser::MX
- Inherits:
-
Object
- Object
- Nesser::MX
- Defined in:
- lib/nesser/packets/rr_types.rb
Overview
Mail exchange record - eg, ‘mail.google.com’ 10.
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#preference ⇒ Object
Returns the value of attribute preference.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, preference:) ⇒ MX
constructor
A new instance of MX.
- #pack(packer) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name:, preference:) ⇒ MX
Returns a new instance of MX.
214 215 216 217 |
# File 'lib/nesser/packets/rr_types.rb', line 214 def initialize(name:, preference:) @name = name @preference = preference end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
212 213 214 |
# File 'lib/nesser/packets/rr_types.rb', line 212 def name @name end |
#preference ⇒ Object
Returns the value of attribute preference.
212 213 214 |
# File 'lib/nesser/packets/rr_types.rb', line 212 def preference @preference end |
Class Method Details
.unpack(unpacker) ⇒ Object
219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/nesser/packets/rr_types.rb', line 219 def self.unpack(unpacker) length = unpacker.unpack_one('n') if length < 3 raise(DnsException, "Invalid MX record") end preference = unpacker.unpack_one('n') name = unpacker.unpack_name() return self.new(name: name, preference: preference) end |
Instance Method Details
#pack(packer) ⇒ Object
231 232 233 234 235 236 237 |
# File 'lib/nesser/packets/rr_types.rb', line 231 def pack(packer) length = packer.pack_name(@name, dry_run: true) + 2 packer.pack('n', length) packer.pack('n', @preference) packer.pack_name(@name) end |
#to_s ⇒ Object
239 240 241 |
# File 'lib/nesser/packets/rr_types.rb', line 239 def to_s() return "#{@preference} #{@name} [MX]" end |