Class: Nesser::NS

Inherits:
Object
  • Object
show all
Defined in:
lib/nesser/packets/rr_types.rb

Overview

Nameserver record: eg, ‘ns1.google.com’.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:) ⇒ NS

Returns a new instance of NS.



76
77
78
# File 'lib/nesser/packets/rr_types.rb', line 76

def initialize(name:)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



74
75
76
# File 'lib/nesser/packets/rr_types.rb', line 74

def name
  @name
end

Class Method Details

.unpack(unpacker) ⇒ Object



80
81
82
83
84
85
# File 'lib/nesser/packets/rr_types.rb', line 80

def self.unpack(unpacker)
  # We don't really need the length for anything, so just discard it
  unpacker.unpack('n')

  return self.new(name: unpacker.unpack_name())
end

Instance Method Details

#pack(packer) ⇒ Object



87
88
89
90
91
92
# File 'lib/nesser/packets/rr_types.rb', line 87

def pack(packer)
  length = packer.pack_name(@name, dry_run: true)
  packer.pack('n', length)

  packer.pack_name(@name)
end

#to_sObject



94
95
96
# File 'lib/nesser/packets/rr_types.rb', line 94

def to_s()
  return "#{@name} [NS]"
end