Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Ruby programs in MAC OS Terminal [duplicate]

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?

like image 621
Ducati007 Avatar asked Oct 16 '12 18:10

Ducati007


People also ask

How do I run ruby on Mac terminal?

Open Interactive Ruby Open up IRB (which stands for Interactive Ruby). If you're using macOS open up Terminal and type irb, then hit enter. If you're using Linux, open up a shell and type irb and hit enter. If you're using Windows, open Interactive Ruby from the Ruby section of your Start Menu.


1 Answers

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.

like image 110
pje Avatar answered Oct 19 '22 15:10

pje