Forum: Ruby No documentation for File's methods?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
699c00ad35f2755810b4aa5f423d73e2?d=identicon&s=25 Albert Schlef (alby)
on 2009-05-07 10:33
We can do the following...

   File.open('somefile.txt')

   File.foreach('somefile')

...and I'm trying to see the documentation for these class methods.

So I execute "ri File#open" and "ri File#foreach" and I get nothing.

I installed fast-ri and I execute "qri File#foreach" and, again, get
nothing.

Interestingly, when I do "qri File#open" I get the documentation for
"Kernel#open". However, File#open isn't kernel#open because the latter
can open a subprocess (as in "cmd = open('|date')"). So I know that "qri
File#open" too doesn't give me the documentation for File#open.

So my question is:

How do I get documentaiton for the methods of class File?
699c00ad35f2755810b4aa5f423d73e2?d=identicon&s=25 Albert Schlef (alby)
on 2009-05-07 10:44
Albert Schlef wrote:
> [snip]
> So I execute "ri File#open" and "ri File#foreach" and I get nothing.

My, my, my. I used '#' instead of '.'. My fault.

But it doesn't change much when I fix my error:

ri "File.open" and "ri File.foreach" return nothing.

"qri File.open" returns documentation for Kernel#open, which isn't
correct.

"qri File.foreach" is an improvement! I get documentation for
IO::foreach. That's good.

But... why doesn't "qri File.open" gives me the documentation for
"IO::open"?

And why the heck doesn't "qri IO.open" give me the documentation for
"IO.open"?!

WWWwwwooooooooooooowwwww!!!

It's like a russian roulette. You shoot in the dark hoping to get
documentation for something, and go figure the meaning of what you get.

I'm sad.
699c00ad35f2755810b4aa5f423d73e2?d=identicon&s=25 Albert Schlef (alby)
on 2009-05-07 10:46
I forgot to mention my software:

ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

ri v1.0.1 - 20041108

fri 0.3.1 (2008-02-02)

(Ubuntu 9.04 system.)
8f6f95c4bd64d5f10dfddfdcd03c19d6?d=identicon&s=25 Rick Denatale (rdenatale)
on 2009-05-07 17:16
(Received via mailing list)
On Thu, May 7, 2009 at 4:33 AM, Albert Schlef <albertschlef@gmail.com>
wrote:
> I installed fast-ri and I execute "qri File#foreach" and, again, get
> nothing.
>
> Interestingly, when I do "qri File#open" I get the documentation for
> "Kernel#open". However, File#open isn't kernel#open because the latter
> can open a subprocess (as in "cmd = open('|date')"). So I know that "qri
> File#open" too doesn't give me the documentation for File#open.
>
> So my question is:
>
> How do I get documentaiton for the methods of class File?

perhaps you need to rebuild the index

fastri-server -b

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
Ba91caa4b1fd66471e4180151b379dd7?d=identicon&s=25 Jörg W Mittag (Guest)
on 2009-05-07 18:16
(Received via mailing list)
Albert Schlef wrote:
> We can do the following...
>
>    File.open('somefile.txt')
>
>    File.foreach('somefile')
>
> ..and I'm trying to see the documentation for these class methods.
>
> So I execute "ri File#open" and "ri File#foreach" and I get nothing.

Wrong class: they are defined in IO, File just inherits them.

jwm
8f6f95c4bd64d5f10dfddfdcd03c19d6?d=identicon&s=25 Rick Denatale (rdenatale)
on 2009-05-07 19:09
(Received via mailing list)
2009/5/7 Jörg W Mittag <JoergWMittag+Usenet@googlemail.com>:
>
> Wrong class: they are defined in IO, File just inherits them.

True, but fri/qri finds inherited methods:
$ qri File.open
------------------------------------------------------------ Kernel#open
     open(path [, mode [, perm]] )                => io or nil
     open(path [, mode [, perm]] ) {|io| block }  => obj
------------------------------------------------------------------------
...

$ qri File.foreach
------------------------------------------------------------ IO::foreach
     IO.foreach(name, sep_string=$/) {|line| block }   => nil
------------------------------------------------------------------------
...

I suspect the OP has a corrupted fast_ri index which needs to be
rebuilt.

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
699c00ad35f2755810b4aa5f423d73e2?d=identicon&s=25 Albert Schlef (alby)
on 2009-05-08 09:08
Hi, people! I'm the original poster.

I discovered an error on my part: I should have used '::' instead of
'.'. That's because I'm looking for the class methods. However, that
didn't solve my problem completely:

Rick Denatale wrote:
> True, but fri/qri finds inherited methods:
> $ qri File.open
> [...]

Now, suppose I want the documentation for File::new. What should I do?

I do the following:

$ qri File::new
---------------------------------------------------------------- IO::new
     IO.new(fd, mode_string)   => io
------------------------------------------------------------------------
     Returns a new IO object (a stream) for the given integer file
     descriptor and mode string. See also IO#fileno and IO::for_fd.


That's wrong. I get documentation for IO::new that involves some numeric
'fd' parameter.

How do I get the documentation for File::new?

(I did rebuilt fast_ri's index.)
8f6f95c4bd64d5f10dfddfdcd03c19d6?d=identicon&s=25 Rick Denatale (rdenatale)
on 2009-05-08 13:47
(Received via mailing list)
On Fri, May 8, 2009 at 3:08 AM, Albert Schlef <albertschlef@gmail.com>
wrote:
> Hi, people! I'm the original poster.


>
>
> That's wrong. I get documentation for IO::new that involves some numeric
> 'fd' parameter.
>
> How do I get the documentation for File::new?

I don't know. The problem might be that fastri is behind and recent
changes to rdoc have led to incompatibilities. See the comments here
http://blog.segment7.net/articles/2009/01/28/rdoc-...

I fear that Mauricio has lost interest in his Ruby stuff and appears
to have moved off to other shiny objects.



--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
8f6f95c4bd64d5f10dfddfdcd03c19d6?d=identicon&s=25 Rick Denatale (rdenatale)
on 2009-05-08 13:52
(Received via mailing list)
On Fri, May 8, 2009 at 7:46 AM, Rick DeNatale <rick.denatale@gmail.com>
wrote:
>>     IO.new(fd, mode_string)   => io
> I don't know. The problem might be that fastri is behind and recent
> changes to rdoc have led to incompatibilities. See the comments here
> 
http://blog.segment7.net/articles/2009/01/28/rdoc-...
>
> I fear that Mauricio has lost interest in his Ruby stuff and appears
> to have moved off to other shiny objects.

It looks like the solution is to go back to using ri rather than
fri/qri, sigh.  The ri command now uses a cache so that after the
first time, it's faster than it used to be.


--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
This topic is locked and can not be replied to.