From: Yohanes Santoso Date: 2002-05-20T14:07:23+09:00 Subject: Re: what's the calling method name? wconrad@yagni.com writes: > There is an experimental patch at > http://yagni.com/stack_frames/index.php that lets you find out the > caller's class. It's against Ruby 1.6.5; let me know if it won't > apply to whatever later version of Ruby you're using and I'll fix it > up. > Thanks Wayne for the patch. This is very useful. Is there a plan to RCR this? After applying the patch (no conflict), the assertion test ran successfully. I also tested from irb: irb(main):003:0> caller = stack_frames[1] # file=/usr/local/stow/ruby-1.6.7/lib/ruby/1.6/irb/workspace.rb line=51> irb(main):004:0> caller.class "Object" irb(main):005:0> caller.function "irb_binding" But I experienced some problem when incorporating it into my code: jenny:/tmp2/freeride> ruby -v ruby 1.6.7 (2002-03-01) [i686-linux] jenny:/tmp2/freeride> ./run.bat ./plugins/remacs/documentation.rb:34:in `stack_frames'(DocumentationTestClass): NULL pointer given (ArgumentError) from ./plugins/remacs/documentation.rb:34:in `insert_via_stack_frame' from ./plugins/remacs/documentation.rb:131:in `test_insert_with_info_from_stack_frames' from ./freebase/databus.rb:697 The corresponding code is: 32 def insert_via_stack_frame(doc) 33 begin 34 caller = stack_frames[1] 35 #puts $STDERR, caller.class 36 #puts $STDERR, caller.function 37 #puts $STDERR, doc 38 insert(caller.class, caller.function, doc) 39 rescue NameError 40 @bus["/log/error"] << "Trying to use the single-argument Documentation::insert without patching ruby" 41 @bus["/log/error"] << $! 42 puts $STDERR, $! 43 end 44 end