Can you give me an example?



I’m trying to write some code with Ruby. I need to write a DNS resolver.
I saw a resolv.rb but there is simple example that I can take.
Specifically, I need:

  • Create object r (that resolvs my dns): something like r =
  • Put hostname and ip in this object: something like r.add(hostname, ip)
  • Consult if this object knows anything about a specific hostname:
    something like r.query(hostname) --> ip
    and consult if this object knows anything about a specific ip:
    something like r.query(ip) --> hostname
  • Specify what it has to do if it does not know nothing about a concrete
    hostname or ip:
    something like
    r.parentresolver(none) --> if r does not know ip of one hostname,
    then there is no procedure for determining it
    r.parentresolver(ip) --> the parent DNS for resolv unknown

I know that all of that can do with resolv.rb but I don’t know how.
Can you put me an example of how do it?

Thank you very much,