How to run Ruby programs in MAC OS Terminal

24,383

Solution 1

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.

Solution 2

I think, this is very simple task. Paste in terminal ruby <your script name>.rb

This is all. Ruby is interpreted lang. Compiler doesn`t exist at all. Only interpreter. I use Ruby only few times, but I think, you must run your method hello. Your code only create the class and nothing else. You should firstly learn Ruby and then RoR.

Share:
24,383
Ducati007
Author by

Ducati007

Updated on July 05, 2022

Comments

  • Ducati007
    Ducati007 almost 2 years

    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?