From: Peter Suk Date: 2005-04-24T06:53:02+09:00 Subject: Re: Abstract Class in ruby On Apr 23, 2005, at 2:14 PM, Paulo S�rgio wrote: > Hi all, > > My question is very "simple" ... how to define an abstract class (or > method) in ruby? Paulo brings up a key issue. We should have a standard "subclass_responsibility" method to denote this for methods. If there is s standard idiom for Ruby, then code tools will be able to identify purely abstract classes. (Classes that have no concrete methods at all.) But to elaborate, nothing prevents someone from putting concrete methods into an abstract class. Ruby is not about enforcement. If you want to communicate this, there is an idiom in Smalltalk where people define a class-side method isAbstract like: ---- code follows ---- class Node def Node.abstract? return self == Node end end ---- end code ---- Now you can make subclasses of Node and they will automatically return false when asked "abstract?" If one of your subclasses also turns out to be abstract, just write a similar method. Now if you want to know if a class is abstract, you can just ask. --Peter -- There's neither heaven nor hell, save what we grant ourselves. There's neither fairness nor justice, save what we grant each other.