From: MonkeeSage Date: 2007-12-28T02:14:58+09:00 Subject: Re: about method docs On Dec 27, 10:23 am, Santanu wrote: > On Dec 27, 8:05 pm, MonkeeSage wrote: > > > > > On Dec 27, 8:22 am, Santanu wrote: > > > On Dec 27, 6:56 pm, Jeremy McAnally wrote: > > > > > I believe you can use `help`. For example: help puts > > > Yes, I did try things like 'help puts', but all I get are these error > > > messages: > > > ------------------------------------------- > > > irb(main):032:0> help puts > > > > No ri documentation found in: > > > > Was rdoc run to create documentation? > > > ......... > > > ------------------------------------- > > > > I use Ubuntu 7.10, and I have already installed rdoc. I don't > > > understand > > > the error message much but it seems I have to do something else to > > > make the help command work. Do I have to install ruby source and run > > > rdoc through them? > > Maybe there are ri / ruby-doc / ruby-dev packages that provide the > > docs? You shouldn't have to build from source...I can't imagine the > > maintainers of Ubuntu would leave it out altogether. But I could be > > wrong...in which case here is a guide for building ruby from source on > > ubuntu (it's easy :)http://www.rubywizards.com/viewtopic.php?pid=19 > > Thanks. Just now I compiled ruby-1.9 and installed it with docs. Now, > at least > help command at the irb prompt provides some help. 'help puts' is > still > problematic though, but things like 'help Array' does give some > understandable > result. > > However, I am still searching for the exact syntax for asking for help > on say, Array.collect, etc. at the irb prompt. Any pointers? > > Regards, > Santanu Sure, be glad to. :) # help about the instance method "reverse_each" # (found in class Array). help "send" # if multiple methods match, it will give a list with # the qualifying namespaces. note that symbols can be # used rather than strings as the argument to #help help :index # instance method "each_slice" of Enumerable module. # note the string use, so that ruby doesn't try to # call each_slice on a Symbol object (:Enumerable) # note also that the "#" could be spelled as "." # and ri doesn't care; but "#" is the usual spelling # you'll see round here when speaking about methods help "Enumerable#each_slice" # help about an instance method of a module nested # in a class. note the string again. like in ruby # itself, access to a class/module-level constant # (in this case a module) is done with "::". but # for instance-level, we use "#" / "." (only the "." is valid in actual ruby code) help "OptionParser::Completion#complete" # help about a class method of a class nested # in a class. note again the syntax difference, # "#" / "." vs. "::". help "OptionParser::Switch::guess" Ps. The examples I used aren't the most enlightening, I just opened a random stdlib file and looked at the first instances of what I was trying to exemplify; so don't think that all (or even most) of the ruby documentation is as cryptic or unhelpful as, for example, the output from ` help "OptionParser::Switch::guess"` heh! ;) Regards, Jordan