Try Ruby
We hope our tour of Ruby’s key features has piqued your interest and you are eager to try Ruby out. To do that, you’ll need a Ruby interpreter, and you’ll also want to know how to use three tools—irb, ri, and gem—that are bundled with the interpreter. This section explains how to get and use them.
The Ruby Interpreter
The official web site for Ruby is http://www.ruby-lang.org. If Ruby is not already installed on your computer, you can follow the download link on the ruby-lang.org home page for instructions on downloading and installing the standard C-based reference implementation of Ruby.
Once you have Ruby installed, you can invoke the Ruby
interpreter with the ruby command:
% ruby -e 'puts "hello world!"' hello world!
The -e command-line option
causes the interpreter to execute a single specified
line of Ruby code. More commonly, you’d place your Ruby program in a
file and tell the interpreter to invoke it:
% ruby hello.rb hello world!
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access