How to run Ruby programs in MAC OS Terminal

Ducati007 picture Ducati007 · Oct 16, 2012 · Viewed 23.6k times · Source

Possible Duplicate:
How to run ruby files?

I am starting to learn Ruby and having a hard time running the Ruby classes in the Terminal.

I created a class in the Sublime Text editor, just "hello world". I can compile using ruby hello.rb, but how do I execute it?

I went to the terminal in my root directory and typed rails c which gave me a console. Could some one please tell me how to create an instance? Which console do I use?

Answer

pje picture pje · Oct 16, 2012

Ruby is interpreted, so you don't need to worry about a separate compile step. ruby hello.rb is the execution command.

The standard interactive shell (REPL) is irb.