More on Ruby Methods

If objects (such as strings, integers and floats) are the nouns (the part of speech, in English, that is used to name a person, place, thing, quality, or action) in Ruby language, then methods are the verbs (the part of speech that expresses existence, action, or occurrence in most languages). Every method needs an object. It's usually easy to tell which object is performing the method: it's what comes right before the dot. Sometimes, though, it's not quite as obvious. When we are using puts, gets - where are their objects? In Ruby, the implicit object is whatever object you happen to be in. But we don't even know how to be in an object yet; we've always been inside a special object (main) Ruby has created for us that represents the whole program. You can always see what object you are in (current object) by using the special variable self.

For more details on self, refer here.

Note: The Ruby Logo is Copyright (c) 2006, Yukihiro Matsumoto. I have made extensive references to information, related to Ruby, available in the public domain (wikis and the blogs, articles of various Ruby Gurus), my acknowledgment and thanks to all of them. Much of the material on and in the course at is drawn primarily from the Programming Ruby book, available from The Pragmatic Bookshelf.