[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
- If you know how to program and want to quickly learn the basics of Ruby: Ruby in Twenty Minutes
- If you already know C, C++, Java, Perl, PHP or Python see this: Ruby From Other Languages
- More pointers to manuals, books and references: Ruby Documentation
- To learn more about RubyGems: Introduction of RubyGems
Comments
Post a Comment