I’m so pleased with my brief experience with Ruby that I’ve decided to make it my primary language of choice.

I’ve taken my time getting started with Ruby, ramping up only recently, and I’ve found it to be a very comfortable ride. What lies ahead seems a little foreign, but I have a feeling that its going to be a very enjoyable learning process.

So far there have been very few hurdles. Here are some that I’ve encountered:

Include a Ruby file within another Ruby file

Sounds easy, right? Well it is easy, but there is a little gotcha which had me hung up for awhile. Say I have a file which creates a variable, and I want to include that file into another, and then reference that variable. That is very much doable, but not the way I was trying to do so.

I’ve recently gotten in the habit of using local variables quite a lot in my ruby scripts, like so:

barf = "blah"

Simple and easy. However, if I put that into barf.rb and then do this in blah.rb:

load "barf.rb"
puts barf

I get an error about an unknown variable barf. I’m not sure if its possible to reference that local variable with some prefix of sorts, but I have discovered that this:

$barf = "blah"

and

load "barf.rb"
puts $barf

works fine. The $ makes it a global variable, and the @@ works too.

eRuby is an external binary

I tried out ERB, and then I read that eRuby is like ERB, but coded in C. Cool! How do I use it? It may be like ERB in that it can parse templates with ERB-comparible syntax, but it isn’t a ruby object which can be instantiated like

barf = ERB.new()

I guess its used more as a we server filter, like with mod_ruby or similar. This can make Ruby behave a little like PHP, which some people may appreciate.

Also a big thanks to the pragmatics guide to Ruby. Its a good read and I may just pick up the pickaxe version for Ruby 1.9!

Ruby version 1.9 is still very new, and this book has already received 62 reviews for an average of 4.5 / 5 stars! That is very impressive.

I have a book on using Ruby for systems administration. I should re-read that before buying another book though.

¥