You should look at some of the examples for Net::SSH, it basically opens a connection and gives you a block to execute whatever command you like, e.g.:
#!/usr/bin/env ruby
require 'rubygems'
require 'net/ssh'
HOST = '192.168.1.113'
USER = 'username'
PASS = 'password'
Net::SSH.start( HOST, USER, :password => PASS ) do|ssh|
output = ssh.exec!('ls')
puts output
end
(taken from here)
I haven't done anything with it, but you get the idea. Given this construct you can run whatever program you like on the remote server and parse its output. As you are probably interested in public key authorization you should have a look at the answer to this question, it will show you how to specify a key-file.