Listing of hosts in a LAN or domain name group?

What's the preferred ruby way of listing hosts in a LAN or within a
domain group?

In particular, I am interested in 4 things:
   - Listing all connected hosts in a LAN / domain group (assuming
there could be some hosts
     that appear and disappear, like wifi hosts -- ie. not just /etc/
hosts ).
  - Listing all hosts with a particular condition (say, allowing
authenticated ssh connections).
  - Avoiding any hosts that are not in a trusted group (say,
  - Doing it fast.

I'm interested in Linux, mainly, but if the solution is multiplatform,
the better.