How to run Ruby programs in MAC OS Terminal
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.
Ducati007
Updated on July 05, 2022Comments
-
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?