From: ts Date: 2002-07-20T20:13:47+09:00 Subject: Re: Is there any English version of Ruby/tk class documentation like this ? >>>>> "M" == Maggie Xiao writes: M> Thanks, they are really helpful. And I'd like to ask a simple question if M> you don't mind. How to use Objectspace to find it? Be carefull, because this was one of my first scripts in ruby and fatally actually it look very strange for me :-)) First you just ObjectSpace#Each_object to store the classes in a Hash ObjectSpace.each_object do |object| if object.kind_of? Class anc = object.ancestors anc.shift parent = nil mods = [] anc.each do |c| if c.kind_of? Class parent = c if ! parent else mods << c end end $class[parent] ||= [] $class[parent] << [object, mods] end end Then you display the Hash : def affiche(val, level, modu, prev) print " " * level newm = modu - prev mod = if newm.empty? "" else "\t(#{newm.join(' ')})" end puts "* #{val}#{mod}" if $class[val] $class[val].collect { |a| [a, a[0].to_s.upcase] }. sort {|a, b| a[1] <=> b[1] }. each do |a, | affiche(a[0], level + 1, a[1], modu) end end end affiche(Object, 0, [Kernel], []) Guy Decoux