As I delved more into the world of the Ruby Programming language, I am discovering tools and resources that would be of help to someone new to Ruby. I want to log my learnings as I go along in hope that it would benefit anyone who might be trudging down this same path.
I may have jumped the gun when I wrote about using modules in Ruby. To kick-start learning about Ruby, it might be prudent to understand about the syntax of Ruby. There are several gems (pun intended) available online that cover the basics of the Ruby language:
In addition to these guides, there are also tools which are pretty handy for Ruby. For some quick action and experimentations with Ruby, there is always the Interactive Ruby Shell (commonly referred to as IRB). To use the IRB, just launch the Terminal app in Mac OS X and type "irb". Within the IRB, you will be able to enter Ruby commands and have the interpreter respond immediately.
$ irb irb(main):001:0> myArray = [1,2,3,4,5] => [1, 2, 3, 4, 5] irb(main):002:0> myArray.each do |x| irb(main):003:1* puts x irb(main):004:1> end 1 2 3 4 5 => [1, 2, 3, 4, 5] irb(main):005:0>
For quick-access to view Ruby documentation off-line, you can always fall back on the ri documentation viewer. Launch the Terminal app in Mac OS X and invoke "ri" followed by the name of a Ruby class, module or method and ri will pull up the documentation accordingly.
Here are some sample usage of ri:
ri Array ri 'Array#<<' ri Array.each ri Array::new
For any initiate to Ruby, these should be more than enough to get u moving along. Happy learning.