Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




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 :

  1. Goto the below link and download the latest version of Ruby.

    https://www.ruby-lang.org/en/downloads/
    Ruby-Installation1

    Ruby-Installation2

    Ruby-Installation3

    Ruby-Installation4

  2. Then double click on the exe file and install Ruby in your PC.

    << >>
    Ruby-Installation5

    Ruby-Installation6

    Ruby-Installation7

    Ruby-Installation8

    Ruby-Installation9

    Ruby-Installation10

    Ruby-Installation11

  3. 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.
    Ruby-Installation12

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).

  1. Goto the below link and download the latest version of Ruby.

    https://rvm.io
    Ruby-Installation13

  2. Then copy the commands and paste in the Terminal to Install Ruby.

  3. 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.

  1. The first thing we will do is open Notepad in Windows OS.
    Ruby-Installation14

  2. 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.

    puts "Hello World.";

    Ruby-Installation15

  3. Then save with .rb extension. Say FirstProgram.rb.
    Ruby-Installation16

    Ruby-Installation17

  4. Then run using the command ruby FirstProgram.rb.
    Ruby-Installation18

And we are done.


Running a Ruby Program in MAC OS


Let us write a Program that will print Hello World.

  1. The first thing we will do is open TextEdit in MAC.

  2. 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.

    puts "Hello World.";

  3. Then save with .rb extension. Say FirstProgram.rb.

  4. Then run using the command ruby FirstProgram.rb.

And we are done.