« Ruby… Not so bad…

October 25, 2006 • ☕️ 1 min read

Yuppie, finally I have a project and looks nice, we have to use Ruby on Rails and Ajax, so I’m forced to study a bit this language and the framework.

I’m reading Agile Web Development with Rails, really a good book and after a lazy mac os intallation of Locomotive + RadRails, I’ve moved to a more “hacking” installation following the good tutorial on the blog of James Dunkan.

Right now I’m blocking cos the installation, done using ports takes really ages, compliling and downloading what’s needed…

There are some “features” that I really like of Ruby, for example all member variables are private, to access it you have to write a getter, using the keyword attr, if you want only getter just write attr_reader

[ruby]

class Blog
def initialize(title)
@title = title
end
attr_reader :title

[/ruby]

Nice no?

Another cool thing is that Ruby does not have Multiple Inheritance by the way it has the module concept, so you can have methods for free from another class.

A stupid example can be something like this:

[ruby]

module WebPage
def WebPage.toHtml

end

class Blog
require ‘WebPage’

[/ruby]

An you’ll be able to use that Method on the Blog class.