Getting Started With Ruby
Ruby is an exciting dynamic language. It's growing very fast and every single day new people add the awesome Ruby community. Several people have asked me how they can start with Ruby. This is a short post for all of them, about getting started with Ruby.
In Mac OS X, Ruby comes preinstalled, so nothing to do.
In Linux distributions you can install Ruby using your favorite package manager, for example in Ubuntu/Debian
$ sudo aptitude install ruby irb build-essential libopenssl-ruby ruby1.8-dev
In Windows systems you can use RubyInstaller
RubyGems is a package manager for Ruby that provides a standard format for distributing Ruby programs and libraries in a self-contained format called a "gem"
The best way to install RubyGems is downloading the source code and compiling it. Verify if you have any RubyGems version installed in your system and uninstall it. After that, install RubyGems by following the steps described here
Now, you're ready to run your first ruby "program". Edit a new file called hello_world.rb and put this code inside
# hello_world.rb # my first Ruby program puts "Hello World!"
and then execute it
$ ruby hello_world.rb Hello World!
Interactive Ruby Shell (IRB)
IRB is a shell for programming in Ruby. The program is launched from a command line and allows the execution of Ruby commands with immediate response, experimenting in real-time.
$ irb irb(main):001:0> puts "Hello World" => "Hello World" irb(main):002:0> 3*2 => 6
I love this game!
After that, if you're hooked on Ruby and want more, you can read the book Programming Ruby by Dave Thomas.
Don't forget to save in your bookmarks the official Ruby documentation. Everything you'd want to know about Ruby Core classes and his methods can be found here.
Install RVM to manage different Ruby versions