Friday, August 10, 2012

[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.


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\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



Ruby Programming Language

No comments:

Post a Comment