Ruby Language - Study24x7
Social learning Network

Ruby Language

Updated on 21 December 2020
study24x7
Ruby Language
6 min read 2 views
Updated on 21 December 2020

Ruby is a scripting language designed by Yukihiro Matsumoto, also known as Matz. It runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. This tutorial gives a complete understanding on Ruby.

Audience

This tutorial has been prepared for beginners to help them understand the basic to advanced concepts related to Ruby Scripting languages.

Prerequisites

Before you start practicing with various types of examples given in this tutorial, we are making an assumption that you are already aware of computer programs and programming languages in general.


Ruby is a pure object-oriented programming language. It was created in 1993 by Yukihiro Matsumoto of Japan.

You can find the name Yukihiro Matsumoto on the Ruby mailing list at www.ruby-lang.org. Matsumoto is also known as Matz in the Ruby community.

Ruby is "A Programmer's Best Friend".

Ruby has features that are similar to those of Smalltalk, Perl, and Python. Perl, Python, and Smalltalk are scripting languages. Smalltalk is a true object-oriented language. Ruby, like Smalltalk, is a perfect object-oriented language. Using Ruby syntax is much easier than using Smalltalk syntax.

Features of Ruby

  1. Ruby is an open-source and is freely available on the Web, but it is subject to a license.
  2. Ruby is a general-purpose, interpreted programming language.
  3. Ruby is a true object-oriented programming language.
  4. Ruby is a server-side scripting language similar to Python and PERL.
  5. Ruby can be used to write Common Gateway Interface (CGI) scripts.
  6. Ruby can be embedded into Hypertext Markup Language (HTML).
  7. Ruby has a clean and easy syntax that allows a new developer to learn very quickly and easily.
  8. Ruby has similar syntax to that of many programming languages such as C++ and Perl.
  9. Ruby is very much scalable and big programs written in Ruby are easily maintainable.
  10. Ruby can be used for developing Internet and intranet applications.
  11. Ruby can be installed in Windows and POSIX environments.
  12. Ruby support many GUI tools such as Tcl/Tk, GTK, and OpenGL.
  13. Ruby can easily be connected to DB2, MySQL, Oracle, and Sybase.
  14. Ruby has a rich set of built-in functions, which can be used directly into Ruby scripts.

Tools You Will Need

For performing the examples discussed in this tutorial, you will need a latest computer like Intel Core i3 or i5 with a minimum of 2GB of RAM (4GB of RAM recommended). You also will need the following software −

  1. Linux or Windows 95/98/2000/NT or Windows 7 operating system.
  2. Apache 1.3.19-5 Web server.
  3. Internet Explorer 5.0 or above Web browser.
  4. Ruby 1.8.5

This tutorial will provide the necessary skills to create GUI, networking, and Web applications using Ruby. It also will talk about extending and embedding Ruby applications.

What is Next?

The next chapter guides you to where you can obtain Ruby and its documentation. Finally, it instructs you on how to install Ruby and prepare an environment to develop Ruby applications.

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. We would recommend you to go through the following topics first and then proceed further −

  1. Ruby Installation on Linux/Unix − If you are planning to have your development environment on Linux/Unix Machine, then go through this chapter.
  2. Ruby Installation on Windows − If you are planning to have your development environment on Windows Machine, then go through this chapter.
  3. Ruby Command Line Options − This chapter list out all the command line options, which you can use along with Ruby interpreter.
  4. Ruby Environment Variables − This chapter has a list of all the important environment variables to be set to make Ruby Interpreter works.

Popular Ruby Editors

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

  1. If you are working on Windows machine, then you can use any simple text editor like Notepad or Edit plus.
  2. VIM (Vi IMproved) is a 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.
  3. RubyWin is a Ruby Integrated Development Environment (IDE) for Windows.
  4. Ruby Development Environment (RDE) is also a 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
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> endnil
irb(main):005:0> hello
Hello Worldnil
irb(main):006:0>



study24x7
Write a comment...