Class: DNS::Message
- Inherits:
-
Object
- Object
- DNS::Message
- Defined in:
- lib/faildns/message.rb
Instance Attribute Summary collapse
-
#additionals ⇒ Object
readonly
Returns the value of attribute additionals.
-
#answers ⇒ Object
readonly
Returns the value of attribute answers.
-
#authorities ⇒ Object
readonly
Returns the value of attribute authorities.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#questions ⇒ Object
readonly
Returns the value of attribute questions.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Message
constructor
A new instance of Message.
- #pack ⇒ Object
Constructor Details
#initialize(*args) ⇒ Message
Returns a new instance of Message.
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/faildns/message.rb', line 63 def initialize (*args) if args.length > 1 @header, @questions, @answers, @authorities, @additionals = *(args.concat([[], [], [], []])) else raise ArgumentError.new('You have to pass at least 1 parameter.') end if block_given? yield self end end |
Instance Attribute Details
#additionals ⇒ Object (readonly)
Returns the value of attribute additionals.
61 62 63 |
# File 'lib/faildns/message.rb', line 61 def additionals @additionals end |
#answers ⇒ Object (readonly)
Returns the value of attribute answers.
61 62 63 |
# File 'lib/faildns/message.rb', line 61 def answers @answers end |
#authorities ⇒ Object (readonly)
Returns the value of attribute authorities.
61 62 63 |
# File 'lib/faildns/message.rb', line 61 def @authorities end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
61 62 63 |
# File 'lib/faildns/message.rb', line 61 def header @header end |
#questions ⇒ Object (readonly)
Returns the value of attribute questions.
61 62 63 |
# File 'lib/faildns/message.rb', line 61 def questions @questions end |
Class Method Details
.length(string) ⇒ Object
57 58 59 |
# File 'lib/faildns/message.rb', line 57 def self.length (string) string = string.clone end |
.parse(string) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/faildns/message.rb', line 28 def self.parse (string) string.force_encoding 'BINARY' original = string.clone header = Header.parse(string); questions = [] 1.upto(header.questions) { questions << Question.parse(string, original); } answers = [] 1.upto(header.answers) { answers << ResourceRecord.parse(string, original); } = [] 1.upto(header.) { << ResourceRecord.parse(string, original); } additionals = [] 1.upto(header.additionals) { additionals << ResourceRecord.parse(string, original); } Message.new(header, questions, answers, , additionals) end |
Instance Method Details
#pack ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/faildns/message.rb', line 75 def pack result = '' result += @header.pack @questions.each {|question| result += question.pack } @answers.each {|answer| result += answer.pack } @authorities.each {|| result += answer.pack } @additionals.each {|additional| result += additional.pack } return result end |