This is a brief guide to help you to read ruby code examples on
my site. This is not a complete guide to ruby, I only cover
constructs that I use in my articles. I assume you're familiar with
a basic OO language.

The left hand colum contains fragments of code, the right side is
explanation of what that group of fragments means. If you find some
ruby you don't follow, scan down the left to see something similar.

This method is called whenever you create an instance. By
default you create an object with aClass.new(arg1, arg2).
Both arguments are passed to initialize, so you declare an argument
for each argument you'll need. You may also define other class methods
that create new instances with other names.

class Subclass < Superclass

Declare inheritance

{|arg1, arg2| doSomething(arg1, arg2)}
do |arg1, arg2|
doSomething(arg1, arg2)
end
do
doSomething
end

Block

Defines a block, Ruby's name for a Closure. The two syntaxes {}
and do/end are mostly equivalent. The {} form is usually used
for one-liners and the do/end form for multi-line blocks.

May take none or many arguments. Like any
closure can refer to any variable within lexical scope.

Blocks are widely used in Ruby throughout the libraries.

var ||= value

Assign if Nil

Assigns value to var only if var is nil. It's the
equivalent of var = value if nil == var.

The gory detail here comes from the fact that nil is falsy
(meaning nil is treated as false in boolean expressions). So similarly
to expressions like var += 5, this one is equivalent to
var = var || value

Ruby uses newlines as statement delimiters. 96% of the time
this is exactly what you need. Occasionally, however, lines
get to be too long, so langauges that use newlines need a
statement continuation character to allow the statement to
span lines.

Ruby uses several characters to infer statement
continuation. So if you finish a line with a "," in an argument
list, ruby infers that you want to continue the
statement. Similarly if you end a line with a "." for a method
call.