[HOW TO] Install Ruby in Xubuntu

Ruby is an interpreted, dynamic, open source scripting language for easy object-oriented programming. It a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.

In this article will learn how to install the Ruby interpreter and RubyGems in Xubuntu. Then we'll take a quick look at how to run a Ruby program and how to install a gem package.

Install

Open a terminal window and run:

sudo apt-get install ruby rubygems -y

Run a Ruby script

ruby script.rb

Run the interactive interpreter

The irb is a tool to execute interactively ruby expressions read from stdin. Run the command irb and type the Ruby command. Examples:

$ irb
irb(main):001:0> 2**20
=> 1048576
irb(main):002:0> name = gets
XubuntuGeek
=> "XubuntuGeek\n"
irb(main):003:0> name.chop!
=> "XubuntuGeek"
irb(main):004:0> puts "Hello #{name}" + "!" * 3
Hello XubuntuGeek!!!
=> nil

List remote installable gems

gem query --remote | less

Install remote gem

gem install --remote GEM_NAME # replace GEM_NAME with proper name

Resources

References

Ruby Programming Language

Comments

Popular posts from this blog

[HOW TO] Create QR Codes in Xubuntu 12.04

[FIX] VLC is unable to open the MRL (smb://)

Add items to Xfce Applications Menu