Generally there are two ways of execute ruby program.
- Interactive Ruby Cell
- With ruby command
Interactive Ruby Cell (irb): Interactive Ruby Shell (IRB or irb) is a REPL for programming in the object-oriented scripting language Ruby. For this:
- Open terminal.
- Use irb command to open it. Which will open sell script to execute ruby program.
Ruby Command: The extension of ruby file is .rb . Write ruby program to any file with extension with .rb called main.rb. In terminal, change the directory in which ruby file exists and run ruby program with following command.
Here you can see the output of your program.