# Can you give me an example?

**URL:** <https://www.ruby-forum.com/t/can-you-give-me-an-example/63131>\
**Category:** Ruby\
**Created:** [June 12, 2006, 4:03pm UTC](https://www.ruby-forum.com/t/can-you-give-me-an-example/63131 "2006-06-12T16:03:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/ac8455/32.png) [@Xan](https://www.ruby-forum.com/u/Xan)\
**Post date:** [June 12, 2006, 4:03pm UTC](https://www.ruby-forum.com/t/can-you-give-me-an-example/63131/1 "2006-06-12T16:03:48Z")

</div>

Hello,

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 =  
Resolver.new()
- 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  
hostnames

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,  
Xan.
