Ruby is a true object-oriented programming language. It is developed in 1993 by Yikhihiro Matsumoto of Japan. Ruby has characteristics like:
- It’s an open source and is free source available on the internet but it is subject to licence.
- Ruby is considered as a general-purpose and interpreted programming language.
- Ruby could be called as object-oriented programming language.
- Ruby is integrated into Hypertext Markup Language
- Ruby is employed of writing the common gateway Interface scripts.
- It is even going to be embedded into the hypertext Mark up language
- It’s a clean and far simpler syntax that allows a new developer to learn very quickly and easily.
- It’s significantly scalable and large collection programs written in Ruby are easily maintainable.
- Ruby has massive collection of built-in functions which uses directly into Ruby scripts.
Dynamic typing and Duck typing:
Ruby is considered a dynamic programming language. The programs aren’t compiled. Entire the class module and method definition to be built by code when run.
Ruby Environment Setup:
This is about arranging up local environment setup for Ruby Programming language. Ruby installation setup on Linux/Unix. If we’ve planned to go on our development environment on Linux/Unix machine. Before going further we’ve to ensure that to have root privilege. By downloading the zip file of Ruby’s latest version. After downloading the Ruby archive, Unpack it and alter it into the newly created directory
$ tar -xvzf ruby-1.6.7.tgz
$ cd ruby-1.6.7
Now compile and configure the Ascii source code as
When finally install ruby as
$ sy -l root # become a root user
$ make install
$ exit # become the own or actual user
Once this is often installed we‘ve to confirm whole is functioning by fine by issuing the subsequent command like
ruby 1.6.7 (2002-06-04) [i386-netbsd]
Ruby Installation on Windows-
There are some tips to place in or install Ruby on windows
Download the zip file of the latest version of Ruby. Once the downloading is finished the Ruby archive unpack it and also change the newly-created directory. Double click the Ruby 1.6.7 exe file. The Ruby installation wizard starts. Select the next important information page of the wizard and keep moving till the Ruby installer completes installing Ruby. There are some environment variables to set up that aren’t done properly. If we use windows 9x and add all the lines to the c:\autoexec.bat. We should set PATH=”D:\(ruby install directory)\bin;%PATH%”.
After installation see that all is working fine by issuing the following command as
Interactive Ruby provides a shell for experimentation. In this IRB shell we may do the expression results line by line immediately. This tool always installs Ruby so we won’t be having extra to try to do to possess IRB working. Type irb at the command prompt interface and an interactive Ruby session may start as given below:
irb(main):001:0> def hello
irb(main):002:4> out = “Hello dear”
irb(main):003:4> puts out
Consider an example, a sample program of Ruby all Ruby program have an extension .rb. The source code is put in test.rb file follows as
puts “Hello, HiRuby!”
Identifiers are called as name of variables, constants and methods. Ruby identifiers are case-sensitive. That means that ram and RAM are two different identifiers in Ruby. Its names consists of alphanumeric characters and also underscore (_) character.
The reserved words are:
BEGIN, END, do, else, alias, and elsif, next, nil, true, then, undef, unless begin, ensure, false, redo, rescue, until, when, module, defined?, super, _LINE_, in, if, for, while, case, class, in, self, super, retry, false.
Here Document in Ruby
This Here Document in Ruby has with respect to creating the strings for various multiple lines. Following a<< we will notify a string or an identifier to shut the string literal its current lines up to terminator are the values of the string. For example
This is the primary kind of making
here document ie multiple line string.