RUBY - INSTALLATION
To run Ruby Programms in you PC, you need to install Ruby first.
Installation of Ruby for Windows OS
Below are the steps to install Ruby on Windows OS :
×
-
Goto the below link and download the latest version of Ruby.
https://www.ruby-lang.org/en/downloads/
-
Then double click on the exe file and install Ruby in your PC.
<< >>
-
Once Ruby is Installed, you can open the Command Prompt and Type ruby -v.
If the version is shown then Ruby is successfully installed in your system.
Installation of Ruby for MAC OS
Below are the steps to install Ruby on MAC OS :
In MAC OS, Ruby can be installed using RVM(Ruby Version Manager).
-
Goto the below link and download the latest version of Ruby.
https://rvm.io
-
Then copy the commands and paste in the Terminal to Install Ruby.
-
Once Ruby is Installed, you can open the Command Prompt and Type ruby -v.If the version is shown then Ruby is successfully installed in your system.
Now, that we have Installed Ruby. Let us see how we can run a Ruby Program.
Running a Ruby Program in Windows OS
Let us write a Program that will print Hello World.
-
The first thing we will do is open Notepad in Windows OS.
-
Once Notepad is opened. You can type the lines of code there.
And now, since we are trying to print Hello World. One line of code is enough in Ruby.
-
Then save with .rb extension. Say FirstProgram.rb.
-
Then run using the command ruby FirstProgram.rb.
Running a Ruby Program in MAC OS
Let us write a Program that will print Hello World.
-
The first thing we will do is open TextEdit in MAC.
-
Once TextEdit is opened. You can type the lines of code there.
And now, since we are trying to print Hello World. One line of code is enough in Ruby.
-
Then save with .rb extension. Say FirstProgram.rb.
-
Then run using the command ruby FirstProgram.rb.