tags:

views:

221

answers:

7

Ok, so I'm finding it quite difficult to locate documentation for ruby. For instance, I was just trying

f = File.open("some-file.txt","w+")

and then want to check what methods I have available on f after this. I try out the following, just to see what thing I get back from open

ri File.open -> Nothing known about File.open

If I browse to the core docs I learn that File at least doesn't define "open", ok so fine. But the page doesn't mention which modules File mixes in, or inherits from. So I finally write up a small script which runs

p File.open("foo.txt", "w+").methods

which finally delivers the motherload. But this seems quite inefficient (not to mention a raw list of methods isn't the best documentation ever). I know that definitions are all very malleable in Ruby, but how do I best navigate the core docs efficiently? I'm not seeing anything else out there, so I'll assume others have some decent way of navigating them. I'm using Firefox, and the Ctrl+F is global across all frames, making it fairly useless. The seeming lack of any cross-referenced documentation is also bewildering (but maybe it's as good as it gets?) This other SO question is basicly the same, but I'll venture another bump, since it's 10 months old, and the accepted answer isn't really cutting it for me.

What are others doing when curious about what methods are available on some object obtained from the standard classes?

+2  A: 

I use pickaxe. It's not the be all and end all, but it's pretty decent.

wombleton
I think I'm gonna have to go with this. Only document so far which lists inheritance, and mixins. Like you say, not awesome, but a good jumping off point I suppose
Svend
A: 

You can access the documentation on your system from a browser. This details how to set it up.

ennuikiller
A: 

I found Fxri is useful when you want to browse what method is avaiable for certain object. It is default in Ruby windows install package.

http://rubyforge.org/projects/fxri/

pierr
This is alot easier (and fast) to search in, but I'm not seeing anything in there, that couldn't be gleaned from the standard docs. That is, no info on where File inherits the open method from, etc.
Svend
+1  A: 

You can just do ri File and it will give you full info on the File class (including the methods it implements and its superclass) or ri open (which will tell you all the places open is implemented if there are several).

Chuck
My ri File doesn't show anything beyond http://www.ruby-doc.org/core/classes/File.html - It doesn't mention any superclass, or modules it includes.
Svend
That's an installation issue then.
rampion
+1  A: 

I'd suggest RubyBrain.com. This has an AJAX powered search interface, so you can search for a method name without a tussle with the Firefox search. RubyBrain.com currently comes in 3 flavours: 1.8.6, 1.8.7 and 1.9.

RubyBrain itself is a spin-off of the excellent RailsBrain.com, if you're also a Rails developer.

David Waller
+1 for rubybrain. I love being able to search by method name, rather than class.
Matt Grande
A: 

Honestly, I usually just go to google and enter "Ruby [method name]" and what I want is almost always in the top three results. If it's not, I fall back to rubybrain.

Matt Grande
A: 

I use http://apidock.com/ruby for Ruby documentation and the site also features Rails and RSpec documentation.

peku