Run the command below in a shell after installing Ruby. This shows how you can execute simple Ruby programs without creating a Ruby file:
ruby -e 'puts "Hello World"'
You can also feed a Ruby program to the interpreter's standard input. One way to do that is to use a here document in your shell command:
ruby <<END puts "Hello World" END