In the ruby file:

#!/usr/bin/env ruby
puts 'Hello world'

At the command line:

chmod +x ruby.rb

Then you can execute it like this:

./ruby.rb