I'd consider shelling to nmap or its like. It's well tuned to that purpose, being quite fast, and it contains enough different ways to ping to satisfy any need. Here's using nmap to discover all hosts on a segment of my network:
wayne@treebeard:~$ nmap -sP 10.0.0.0/24
Starting Nmap 5.00 ( http://nmap.org ) at 2010-12-08 09:16 MST
Host gw (10.0.0.1) is up (0.00036s latency).
Host 10.0.0.2 is up (0.0071s latency).
Host isengard.internal.databill.com (10.0.0.3) is up (0.00062s latency).
...
Host arod.internal.databill.com (10.0.0.189) is up (0.0046s latency).
Host 10.0.0.254 is up (0.00042s latency).
Nmap done: 256 IP addresses (43 hosts up) scanned in 3.00 seconds
Here we've scanned for all hosts from 10.0.0.0 through 10.0.0.255.
-sP is a "ping scan", a pretty generic host discovery mechanism that can be run as an ordinary user. There are other types of scan that nmap does, many of them needing root privileges.
In Ruby, you'll use backtick or IO.popen to run nmap and capture its results:
output = `nmap -sP 10.0.0.0/24
output.each_line.find_all do |lines|
line =~ /^Host/
end.each do |line|
# Whatever you want to do for each host
end
If you supply the -oX switch, nmap will output xml, which may be easier to parse (thanks, tadman).