Possible Duplicate:
Look up all descendants of a class in Ruby
So, let’s say that we have:
class LivingBeing
class Animal
end
class Bacteria
end
class Virus
end
end
class Fungi < LivingBeing
end
How do I check what subclasses LivingBeing has? I know that we have Klass.ancestors but what’s the method to see the opposite of ancestors?
There’s nothing built into the core Ruby language that will do what you want – you’ll need to write your own. Here’s an example method
subclasses_of(class_name_here)(below) that will return a list of subclasses of a particular class for you:Btw, there’s an answer to this question here:
http://dzone.com/snippets/objectsubclasses