From: John Kaurin Date: 2001-05-09T09:10:09+09:00 Subject: [ruby-talk:14881] Class/Module Information It is possible to modify the following code to produce the desired output rather than the actual output? I (hope I) know things like instance variables do not become "live" until the code is executed and some of the methods cannot be stopped from including superclass information. Just wondering if anyone had any magical tricks :-) I am trying to get all (most) of the information relating (isolated) to a specific module or class. Would anyting change for classes? # Code Starts Here module A CONSTANT_A = "A" @@class_a = nil def func_a @var_a = nil end end module B include A CONSTANT_B = "B" @@class_b = nil def func_b @var_b = nil end end module C include B CONSTANT_C = "C" @@class_c = nil def func_c @var_c = nil end end if __FILE__ == $0 if false # Put test code here. # Change false to true for testing. else print "Name ................. "; p C.name print "Included Modules ..... "; p C.included_modules print "Constants ............ "; p C.constants print "Class Variables ...... "; p C.class_variables print "Instance Variables ... "; p C.instance_variables print "Instance Methods ..... "; p C.instance_methods end end # Code Ends Here Actual Output: Name ................. "C" Included Modules ..... [B, A] Constants ............ ["CONSTANT_C", "CONSTANT_B", "CONSTANT_A"] Class Variables ...... ["@@class_c", "@@class_b", "@@class_a"] Instance Variables ... [] Instance Methods ..... ["func_c"] Desired Output: Name ................. "C" Included Modules ..... [B] Constants ............ ["CONSTANT_C"] Class Variables ...... ["@@class_c"] Instance Variables ... ["@var_c"] Instance Methods ..... ["func_c"]