Assuming you're targeting Mac OS X (Unix) or Linux you can put this line at the top of your Ruby file to make it compatible with the Terminal:
#!/bin/ruby
Basically, this tells the shell (Terminal) to run the contents of the file with whatever executable you write after #!
. In this case, you're instructing it to use the ruby
executable that you use to run your code elsewhere.
To allow the Ruby script to be executed, you'll need to make it executable by running:
chmod a+x my_script.rb
Finally, to get double clicking support, you might have to replace the .rb
extension with .sh
so the operating system recognizes it as a shell script and not a Ruby file.
You might also consider a GUI of some sort. Shoes is a great way to create nice user interfaces, and it's really easy to use. It also allows you to generate executable files for Windows, OS X, and Linux if I remember correctly.
Here's an example, which creates a basic, clickable button:
Shoes.app do
@button = button "Click Me"
@button.click do
puts "Clicked!"
end
end