From: Jens Wille Date: 2008-07-28T02:04:32+09:00 Subject: Re: Is there a simple way to find a method definition? hi dean! Dean Wampler [2008-07-27 16:50]: > Does anyone know of a programmatic way to find the definition? this is exactly what you can do with AddedMethods [1]: require 'rubygems' require 'nuggets/util/added_methods/init' require 'your/library/or/whatever' matches = Util::AddedMethods.find( :name => 'method_name', :class => YourClass # optional ) # get the class(es) where matching method(s) were defined matches.each { |am| puts am[:class] # or am.klass } # assume the first one is the one we're looking for am = matches.first # is it a singleton method? puts am.singleton # where exactly has it been defined? puts "#{am.file}, line #{am.line}" # now get its source puts am # implies #to_s, you can also call #extract_source directly does that help in any way? if you trip over any quirks or even bugs, or if you have any suggestions, please let me know. as i said earlier in this thread, you can get ruby-nuggets, which this library is a part of, from rubyforge [2] or from our own gem server [3]. [1] [2] [3] cheers jens -- Jens Wille, Dipl.-Bibl. (FH) prometheus - Das verteilte digitale Bildarchiv f�r Forschung & Lehre Kunsthistorisches Institut der Universit�t zu K�ln Albertus-Magnus-Platz, D-50923 K�ln Tel.: +49 (0)221 470-6668, E-Mail: jens.wille@uni-koeln.de http://www.prometheus-bildarchiv.de/