From: Robert Klemme Date: 2009-01-29T17:13:16+09:00 Subject: Re: Studying the object model 2009/1/29 Justin Collins : > Albert Schlef wrote: >> >> I'm looking for some study aid. I want to understand Ruby's object model >> better. >> >> Is there some tool that takes some object as input and shows its >> inheritance chain, it's instance and class variables, the singleton >> classes and all? >> >> I've already seen some diagrams that explain how OOP work in Ruby, but >> I'd still like to see all this in my own eyes. >> > > I think you want something more visual than this (?) but you can always just > ask Ruby itself: Here's an easy way to get a visual graph of the currently defined class hierarchy: ruby -r pp -e 'tree = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc)} ObjectSpace.each_object(Class) {|cl| tree[cl.superclass][cl] = tree[cl]} pp tree[Object]' Kind regards robert -- remember.guy do |as, often| as.you_can - without end