Class: Nesser::Question
- Inherits:
-
Object
- Object
- Nesser::Question
- Defined in:
- lib/nesser/packets/question.rb
Instance Attribute Summary collapse
-
#cls ⇒ Object
readonly
Returns the value of attribute cls.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.unpack(unpacker) ⇒ Object
Parse a question from a DNS packet.
Instance Method Summary collapse
-
#initialize(name:, type:, cls:) ⇒ Question
constructor
Create a question.
-
#pack(packer) ⇒ Object
Serialize the question.
- #to_s ⇒ Object
Constructor Details
#initialize(name:, type:, cls:) ⇒ Question
Create a question.
The name is a typical dotted name, like “google.com”. The type and cls are DNS-specific values that can be found in constants.rb.
23 24 25 26 27 |
# File 'lib/nesser/packets/question.rb', line 23 def initialize(name:, type:, cls:) @name = name @type = type @cls = cls end |
Instance Attribute Details
#cls ⇒ Object (readonly)
Returns the value of attribute cls.
15 16 17 |
# File 'lib/nesser/packets/question.rb', line 15 def cls @cls end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/nesser/packets/question.rb', line 15 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
15 16 17 |
# File 'lib/nesser/packets/question.rb', line 15 def type @type end |
Class Method Details
.unpack(unpacker) ⇒ Object
Parse a question from a DNS packet.
32 33 34 35 36 37 |
# File 'lib/nesser/packets/question.rb', line 32 def self.unpack(unpacker) name = unpacker.unpack_name() type, cls = unpacker.unpack("nn") return self.new(name: name, type: type, cls: cls) end |
Instance Method Details
#pack(packer) ⇒ Object
Serialize the question.
42 43 44 45 |
# File 'lib/nesser/packets/question.rb', line 42 def pack(packer) packer.pack_name(@name) packer.pack('nn', type, cls) end |