Ruby is an interpreted scripting language for quick and easy object-oriented programming. Which means:
If you are unfamiliar with some of the concepts above, read on, and don’t worry. The mantra of the ruby language is quick and easy.
The current stable version is 2.3.0. It has various performance improvements and syntactic additions from its predecessor, ruby v2.2.4.
Mac OS X and many Linux distributions come pre-installed with Ruby. To check if ruby is pre-installed in your system, just run
ruby -v on your shell. There are several ways to install Ruby:
To know about how to install Ruby through package managers, installers and source, click here. RVM (Ruby Version Manager) and rbenv are the most popular Ruby managers to manage multiple Rubies. If you get stuck anywhere, don’t worry, just head over to our Gitter chat room and ask us anything.
IRB stands for Interactive Ruby Shell. The abbreviation irb comes from the fact that the filename extension for Ruby is “.rb”, although interactive Ruby files do not have an extension of “.irb”. The program is launched from a command line and allows the execution of Ruby commands with an immediate response, experimenting in real-time. It features command history, line editing capabilities, and job control, and is able to communicate directly as a shell script over the Internet and interact with a live server. It was developed by Keiju Ishitsuka.
irb "Hello World" Hello World! => nilprint
The Ruby interpreter is what is used to run Ruby scripts. If it is available and in Unix shell’s search path makes it possible to start it by typing the command
ruby followed by the script name will invoke the interpreter and run the script.
if 'welcome' == 'welcome' print('Hello campers!') end
$ ruby hello_campers.rb Hello campers!
Ruby is well documented. These docs include tutorials, guides, references and meta information for language. Another important resouce for documentation is Ruby Doc. You should visit this link to know more about Ruby style guide, written by developers of AirBnB.
print some_variable # prints to console
… often the quickest way to debug a program is to add a few print statements to the source: the fast edit-test-debug cycle makes this simple approach very effective.
Ruby also includes more powerful tools for debugging, such as:
print(obj, ...) → nil
Prints each object to $stdout. Objects that aren’t strings will be converted by calling their
to_s method. The return value of print is
nil. So when you run
print "Hello World! in your IRB. The output is:
"Hello World!" Hello World! => nilprint
Ruby has several frameworks for quickly scaffolding applications. The most popular by far is Rails which was initially released in 2004. Other frameworks for Ruby include Sinatra, Lotus, and Volt. Each of these options has their pros and cons for development and cater to a variety needs.
|History of Ruby||Table of Contents||Ruby Strings|