From: Leslie Viljoen Date: 2007-04-14T08:31:44+09:00 Subject: Re: Invisible methods and inheritance On 4/14/07, Ryan Davis wrote: > > On Apr 13, 2007, at 15:42 , Leslie Viljoen wrote: > > > Hello! > > > > Does anyone know the reason for the following? > > > > p rio('.').all.dirs.methods.include?("each") > > p rio('.').all.dirs.methods.respond_to?("each") > > > >> false > >> true > > I think you meant: > > p rio('.').all.dirs.respond_to?("each") > > you don't want to ask the result of methods if IT responds to each, > you want to ask the result of dirs. > > > I can call dirs.each, but I am trying to trace which .each method is > > called in the rio source. > > Don't forget that things like method_missing (and even respond_to?) > can be overridden. > > > Also how can I find the parent/superclass > > class of a class? (ie. something like Array.parent?) > > >> Array.superclass > => Object > > Remember, ri is your friend, just ask it what you asked us and you'll > often find your answer: > > % ri superclass > ------------------------------------------------------- Class#superclass > class.superclass -> a_super_class or nil > ------------------------------------------------------------------------ > Returns the superclass of _class_, or +nil+. > > File.superclass #=> IO > IO.superclass #=> Object > Object.superclass #=> nil > Thanks Ryan. It seems I am much more tired than I thought I was ;-) -- If you could create a machine that copies hamburgers � you put one hamburger in and two equally good hamburgers come out the other side � it would be unethical not to do so and make it freely available.