Gray's Matter
Justice Gray - North America's favorite metrosexual software consultant

I Wish These People Updated More Than Once a Year

With a new day dawns another 5 minutes of Ruby tutorials!  Today's silent screencast covers the following:

Classes in Ruby
Property getters, setters, constructors, inheritance, you name it!  We go over it in a simple example using Donald, Justice, the EDMUG executive and the all-important "hair" property.

Some supplements here:
  • super indicates a call to the parent class
  • < indicates an inheritance: e.g. "Donald < EdmugExec" means Donald inherits from EdmugExec
  • @variable_name indicates an instance variable of a class
Easy reflection in Ruby
Take a look at how quickly we can receive class information in Ruby!  Just ask and it is given.

Hooks
The simulation of the EDMUG executive continues!  Art imitates life as Donald finds there are just some things he can't do, so he gets Justice to do them for him...in this case, using the method_missing hook to delegate failed requests to a different object!  (This will tie in later to an interesting decorator implementation - stay tuned!)

A note here: you'll notice that method_missing is implemented using the following syntax:
def method_missing(method, *args, &block)

The * behind an argument in Ruby means that there are a variable number of arguments.  The & prior to an argument in Ruby converts a block (if there is one) into a Proc object. 

You can modify anything in Ruby
What happens if we want to add the infamous swinging lightsaber method to the Donald class at run-time?  What if we just want to add it to one *instance* of the Donald class?   Anything is possible!!

You can modify anything in Ruby, so let's not get retarded
I don't think this needs any further explanation ;)

If you somehow missed the link above, download installment 4 right here!


Wednesday, October 18, 2006 #

10/20/2006 6:12:34 PM (Mountain Daylight Time, UTC-06:00)
Looks like John Lam is going to work at Microsoft:

http://www.iunknown.com/articles/2006/10/20/dynamic-languages-microsoft-and-me
11/2/2006 5:17:26 PM (Mountain Daylight Time, UTC-06:00)
Jesus fucking christ buddy! You make it sound like Ruby is _new_ technology - never been done before anywhere. What kind of software consultant are you? C#? Oh... Well that explains a lot.
11/2/2006 5:21:30 PM (Mountain Daylight Time, UTC-06:00)
Hey guru!!

Ruby is definitely not anything new - as I was saying in an earlier post it's actually been around since 1995. It's only taken off with the advent of Rails.

I know it sounds like I'm totally taking the kid gloves in this series, but there are actually still a lot of .NET devs who are not only totally unfamiliar with Ruby but unfamiliar with dynamic languages as a concept. It's mostly designed as some intro level stuff (all of the pieces of this are part of my "Intro to Ruby" presentation).

Thanks for the feedback! So are you more into Ruby or .NET in general?


Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):