From: Daniel Berger Date: 2006-12-02T20:50:12+09:00 Subject: Re: cidr.rb: port of Perl's Net::CIDR v0.11 available Jos Backus wrote: > On Sat, Dec 02, 2006 at 06:03:59AM +0900, Daniel Berger wrote: > > Hm, I'll have to think about the API. I suppose the most simple > > approach is to just add accessors for duration and ip_address (with a > > 'nil' value by default). In practice, then, your code would look like this: > > > > if p.ping? > > puts p.ip_address > > puts p.duration > > end > > > > How does that look? > > I like this much better than the positional API that Perl uses here ("Is > duration the 1st or 2nd return value?"). Plus it makes it easy to add futher > items down the road without breaking existing code. +1. Ok, I'll add those. However, don't put too much stock in the duration. Looking at the Perl code, it isn't much more than this: start = Time.now p.ping? duration = Time.now - start And you can get the ip via IPSocket.getaddress(host) Regards, Dan