From: Josh Cheek Date: 2011-05-23T02:13:42+09:00 Subject: Re: Ruby Clasess --90e6ba53b090fa393804a3e079bd Content-Type: text/plain; charset=ISO-8859-1 On Sun, May 22, 2011 at 12:11 PM, Josh Cheek wrote: > class Animal > > def self.inherited(subclass) > children << subclass > end > > def self.children > @children ||= [] > end > > def self.descendants > children.map do |child| > [child].concat child.descendants > end.flatten > end > > end > > Dog = Class.new Animal > Cat = Class.new Animal > Tabby = Class.new Cat > > RUBY_VERSION # => "1.9.2" > Animal.children # => [Dog, Cat] > Animal.descendants # => [Dog, Cat, Tabby] > > Cat.descendants # => [Tabby] > > Accidentally pasted the code over the entire response >.< I meant to say you could whip something up without too much effort (as 7stud said, there is no standard way). --90e6ba53b090fa393804a3e079bd--