I have the following script:
#!/usr/bin/env ruby require \'rubygems\' require \'net/ssh\' Net::SSH.start(\'host1\', \'root\', :password => \"mypassword1\
ssh.exec("cd /var/example/engines/; pwd")
That will execute the cd command, then the pwd command in the new directory.
cd
pwd
I'm not a ruby guy, but I'm going to guess there are probably more elegant solutions.