This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.
# TracePoint.defined_class (from ruby core) --- defined_class() --- Return class or module of the method being called. class C; def foo; end; end trace = TracePoint.new(:call) do |tp| p tp.defined_class #=> C end.enable do C.new.foo end If method is defined by a module, then that module is returned. module M; def foo; end; end class C; include M; end; trace = TracePoint.new(:call) do |tp| p tp.defined_class #=> M end.enable do C.new.foo end **Note:** #defined_class returns singleton class. 6th block parameter of Kernel#set_trace_func passes original class of attached by singleton class. **This is a difference between Kernel#set_trace_func and TracePoint.** class C; def self.foo; end; end trace = TracePoint.new(:call) do |tp| p tp.defined_class #=> #<Class:C> end.enable do C.foo end
This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.