Top Level Namespace

Defined Under Namespace

Modules: Net Classes: RawSocket, UdpRawSocket

Instance Method Summary collapse

Instance Method Details

#Resolver(name, type = Net::DNS::A, cls = Net::DNS::IN) ⇒ Object

Resolver helper method.

Calling the resolver directly:

puts Resolver("www.google.com").answer.size
# => 5

An optional block can be passed yielding the Net::DNS::Packet object.

Resolver("www.google.com") { |packet| puts packet.size + " bytes" }
# => 484 bytes


19
20
21
22
23
24
25
26
# File 'lib/net/dns/resolver.rb', line 19

def Resolver(name, type = Net::DNS::A, cls = Net::DNS::IN)
  resolver = Net::DNS::Resolver.start(name, type, cls)
  if block_given?
    yield resolver
  else
    resolver
  end
end