Day of Ruby
May 17th, 2009A Day of Ruby discussion and hands-on learning event was held in downtown Tampa on Saturday May 16th. Marc B. brought this event to my attention. Being a free event where I can learn something new compelled me not to sleep in on a Saturday morning. My last glance at Ruby was a year and a half-ago.

The Day of Ruby will travel to Orlando, FL on Saturday, May 30th. More information about the Orlando event is located here.
The discussion was divided into the following parts:
- Introduction to Ruby.
- Hands-on learning with Rails and Cucumber, an approach to writing acceptance tests at a business level.
- Hands-on learning with Shoes, a basic UI toolkit.
- Discussion about JRuby.
- Discussion about IronRuby.
The first part was an overview on the features of Ruby.
Introduction to Ruby
Presenter: Corey Haines
Document: It Really is Love
Notes:
- Every method returns the value of the last statement.
- The assignment operator (=) returns the value that was assigned.
Duct-typing
- Focuses more is on interaction. A type does not equal a class.
Blocks
a = [5, 7, 10, 24] a.each do |num| puts num end
Output:
5
7
10
24
b = a.map do |num| num * 2 end puts b.inspect
Output:
10
14
20
48
Examples of using the yield statement…
Open Classes
- Alters the definition of a class on the fly.
- Mix-ins can alter a class by adding a methods at run-time.
Example:
current_time = 17
The above example sets the current time to 17, on a 24-hour clock. It would be nice to be able to set the time, on a 12-hour clock, like this:
current_time = 5.pm
To accomplish this change the definition of the Fixnum class.
class Fixnum
def pm
self + 12 # Every method returns the value of the last statement.
end
end
- Ruby is a language that allows you to build a tool to get what you want done.
- Builder is an XML utility class.
method_missing(sym, *args, &block) – This method is called when a class does not have a method assigned to it.
Hands on Learning with Rails and Cucumber
This section begins with a brief Rails overview followed by a hands-on learning session. Below are notes during the brief rails overview. I’ll have to follow-up with a second posting concerning the to-do list Rails web application using Cucumber. It’s something that I never seen before.
Presenter: Cory Foy
Notes:
Rails, a framework to build websites, originated from 37 Signals (Dave Hansson).
Foundational patterns:
- MVC
- Active Record
Rails Components
- Active Record
- Support – Helper classes
- Pack – Wraps things
- Mailer – Sends out e-mail
- Resources – Maps resources (e.g. URLs)
Diagram of MVC Rails workflow…
Testing Frameworks
- RSpec – Defines from a code level what it should be doing.
- Cucumber – Higher level. Writing specifications in a language that defines behavior. Written in plain language.
Implementations of Ruby in other programming languages.
- IronRuby – .NET implementation
- JRuby – Java implementation