On 1/16/06, Tom Allison <tallison / tacocat.net> wrote:
> But it would be *really* useful if there was something in the docs to
> delineate where methods come from if they aren't provided in the core.

Two tricks helped me to determine where the method is defined:

1) Every rdoc page mentions at the top which files the methods are
defined in. For example, the Integer core rdoc page[1] has the
following near the top:

   Class   Integer
   In:     numeric.c
           lib/rational.rb
   Parent: Numeric

From the file it's often possible to guess the library. In this case,
the header doesn't tell us enough to be sure whether lcm is coming
from; from numeric.c (ie. inheritance from Numeric) or
lib/rational.rb.

2) Going to the documentation for the actual method[2], you can click
on the method name and it will show you the source for the method[3],
preceded by a comment telling you the file name and line number[4].
Having narrowed it down to one file, we can again try to guess the
library name.

I'll agree with you that it should be easier to determine the library
that defined the method. But in the meantime, these tricks can help.

Jacob Fugal

[1] http://www.ruby-doc.org/core/classes/Integer.html
[2] http://www.ruby-doc.org/core/classes/Integer.html#M000283
[3] http://www.ruby-doc.org/core/classes/Integer.src/M000283.html

[4] At least for the methods I checked. lcm has it. A few other of the
pure ruby methods had it. Some C methods I checked didn't, but seeing
that they were C was enough to give them away. YMMV.