Class: Latte::Query
Defined Under Namespace
Classes: QueryHeader, QueryRequest
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
102
103
104
105
106
|
# File 'lib/latte/query.rb', line 102
def method_missing *args
result = parsed_record.send *args
return result.value if result.respond_to? :value
result
end
|
Instance Method Details
#build_record ⇒ Object
93
94
95
96
97
98
99
100
|
# File 'lib/latte/query.rb', line 93
def build_record
case .qr.value
when 0
QueryRequest.read raw_query
else
raise "Unhandled QR value: #{.qr.value}"
end
end
|
108
109
110
111
112
|
# File 'lib/latte/query.rb', line 108
def
"ID=#{id} QR=#{qr} TC=#{tc} RD=#{rd} RA=#{ra} Z=#{z} " + \
"RCODE=#{rcode} QDCOUNT=#{qdcount} ANCOUNT=#{ancount} " + \
"NSCOUNT=#{nscount} ARCOUNT=#{arcount}"
end
|
#human_qname ⇒ Object
114
115
116
117
118
119
|
# File 'lib/latte/query.rb', line 114
def human_qname
value = parsed_record.qname.value.dup
value.gsub! /^[\x00-\x1f]/, ''
value.gsub! /[\x00-\x1f]/, '.'
value + '.'
end
|
121
122
123
|
# File 'lib/latte/query.rb', line 121
def query
"QNAME=#{human_qname} QTYPE=#{qtype} QCLASS=#{qclass}"
end
|
125
126
127
|
# File 'lib/latte/query.rb', line 125
def to_s
[ , query ].join " "
end
|