def to_s_with_rcode(rcode)
if @opcode == OpCode::Update
s = ";; id = #{@id}\n"
s << ";; qr = #{@qr} opcode = #{@opcode.string} rcode = #{@rcode.string}\n"
s << ";; zocount = #{@qdcount} "
s << "prcount = #{@ancount} "
s << "upcount = #{@nscount} "
s << "adcount = #{@arcount}\n"
s
else
flags_str = begin
flags = []
flags << 'qr' if @qr
flags << 'aa' if @aa
flags << 'tc' if @tc
flags << 'rd' if @rd
flags << 'ra' if @ra
flags << 'ad' if @ad
flags << 'cd' if @cd
";; flags: #{flags.join(' ')}; "
end
head_line_str =
";; ->>HEADER<<- opcode: #{opcode.string.upcase}, status: #{@rcode.string}, id: #{@id}\n"
section_counts_str =
"QUERY: #{@qdcount}, ANSWER: #{@ancount}, AUTHORITY: #{@nscount}, ADDITIONAL: #{@arcount}\n"
head_line_str + flags_str + section_counts_str
end
end