Ruby classes reloaded
» Tagged as: Ruby
We have already discussed that you can override methods in classes in an adhoc manner, but there is no way to overload methods. A great pity.
self was previously put forth as a reference to the current object, however it can also be used to define 'static' methods, better known as class scope methods.
def self.class_scope_method
some code
end
Ruby reflection if you can call it that, is rather interestingly. You can call instance_methods on an object and it will produce a listing of all the methods that are available.
Some of the tidbits in this post is thanks largely to knowledge gathered from http://juixe.com/techknow/index.php/2007/01/22/ruby-class-tutorial/ and some of it from http://www.ruby-lang.org/en/documentation/quickstart