Ruby - Environment Setup

Try it Option Online

You really do not need to set up your own environment to start learning Ruby programming language. Reason is very simple, we already have set up Ruby Programming environment online, so that you can execute almost all the tutorial examples online at the same time when you are doing your theory work. This gives you confidence in what you are reading and to check the result with different options. Feel free to modify any example and execute it online.

Try following example using Try it option available at the top right corner of the below sample code box:

#!/usr/bin/ruby -w

puts "Hello, Ruby!";

For most of the examples given in this tutorial, you will find Try it option, so just make use of it and enjoy your learning.

Local Environment Setup

If you are still willing to set up your environment for Ruby programming language, then let's proceed. This tutorial will teach you all the important topics related to environment setup. I would recommend to go through the following topics first and then proceed further:

Popular Ruby Editors:

To write your Ruby programs, you will need an editor:

  • If you are working on Windows machine, then you can use any simple text editor like Notepad or Edit plus.

  • VIM (Vi IMproved) is very simple text editor. This is available on almost all Unix machines and now Windows as well. Otherwise, your can use your favorite vi editor to write Ruby programs.

  • RubyWin is a Ruby Integrated Development Environment (IDE) for Windows.

  • Ruby Development Environment (RDE) is also very good IDE for windows users.

Interactive Ruby (IRb):

Interactive Ruby (IRb) provides a shell for experimentation. Within the IRb shell, you can immediately view expression results, line by line.

This tool comes along with Ruby installation so you have nothing to do extra to have IRb working.

Just type irb at your command prompt and an Interactive Ruby Session will start as given below:

irb 0.6.1(99/09/16)
irb(main):001:0> def hello
irb(main):002:1> out = "Hello World"
irb(main):003:1> puts out
irb(main):004:1> end
irb(main):005:0> hello
Hello World

Do not worry about what I did here. You will learn about all these steps in subsequent chapters.

What is Next?

I assume now you have a working Ruby Environment and you are ready to write first Ruby Programs. Next chapter will teach you how to write Ruby programs.