From: Dave Howell on

On Jul 21, 2010, at 1:39 , James O'Brien wrote:

> Hi,
>
> I've been trying to learn about and use the ruby File class.
>
> when I look at the documentation:
>
> http://ruby-doc.org/core/classes/File.html
>
> I cant see any mention that File < IO (it is a subclass and hence there are
> a whole load of useful methods)

Wow, that's not helpful. That page looks nothing like my local HTML documentation.

First sentence: "A File is an abstraction of any file object accessible by the program and is closely associated with class IO. File includes the methods of module FileTest as class methods, allowing you to write (for example) File.exist?("foo")."

{dig dig}

Aha.

Don't use the 1.8.6. core docs. At least not for File! Use at least the 1.8.7 ones.



From: Charles Oliver Nutter on
On Wed, Jul 21, 2010 at 4:13 PM, Hassan Schroeder
<hassan.schroeder(a)gmail.com> wrote:
> ------------------------------------------------------------ Class: File
> $ jruby --1.9 -S ri File | head -n 1
> --------------------------------------------------- Class: File < Object

Heh, that makes no sense :)

FWIW, we don't ship ri docs for 1.8, so I'm not sure exactly where
this is coming from. Someone needs to hack a better single-file format
for rdoc; belching thousands of files to the filesystem and searching
them every time is pretty gross.

On the other hand, JRuby does have some interesting tweaks to ri:


~/projects/jruby ➔ ri --java java.lang.String
----------------------------- Class: java.lang.String < java.lang.Object
(no description...)
------------------------------------------------------------------------


Class methods:
--------------
copyValueOf, format, valueOf


Instance methods:
-----------------
charAt, codePointAt, codePointBefore, codePointCount, compareTo,
compareToIgnoreCase, concat, contains, contentEquals, endsWith,
equals, equalsIgnoreCase, getBytes, getChars, getClass, hashCode,
indexOf, intern, isEmpty, lastIndexOf, length, matches, notify,
notifyAll, offsetByCodePoints, regionMatches, replace, replaceAll,
replaceFirst, split, startsWith, subSequence, substring,
toCharArray, toLowerCase, toString, toUpperCase, trim, wait

- Charlie

From: Eric Christopherson on
On Wed, Jul 21, 2010 at 6:02 PM, Joel VanderWerf
<joelvanderwerf(a)gmail.com> wrote:
> James O'Brien wrote:
>>>
>>> I cant see any mention that File < IO (it is a subclass and hence there
>>> are
>>> a whole load of useful methods)
>
> FWIW,
>
> $ ri File | head -n 1
> File < IO

James was referring to http://ruby-doc.org/core/classes/File.html ,
which indeed does not tell about inheritance from IO anywhere in it.
That page is for Ruby 1.8.6, although you wouldn't know it by looking.
To add to the confusion, that page seems to be actually describing
ftools.rb, which adds methods to File; not the File class itself.

For me, under 1.9.1p429 (RubyInstaller) under Windows, ri File says only this:

(begin)
------------------------------------------------------- Class: File < IO
[no description]
------------------------------------------------------------------------


Class methods:
--------------

binread
(end)

ri IO shows:
(begin)
More than one method matched your request. You can refine your
search by asking for information on one of:

TkItemConfigMethod::__IGNORE_UNKNOWN_CONFIGURE_OPTION__ [gem tk_as_gem-0.1.0]
TkItemConfigMethod::__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__! [gem
tk_as_gem-0.1.0]
(end)

Is something missing from my Ruby installation? The online version at
http://ruby-doc.org/ruby-1.9/classes/File.html is quite detailed.

Jruby 1.5 ri shows detailed information for File and IO, although
again its page for File is about ftools.rb, and it doesn't say File <
IO. I get this both on Windows and Mac OS X. Charles, you don't know
where this is coming from??

Finally, even though the 1.8.7 doc at
http://ruby-doc.org/core-1.8.7/classes/File.html seems to describe the
actual class, when I run ri File in Mac OS X using 1.8.7 I also get
the spiel about ftools.rb instead of File per se.

From: Dave Howell on

On Jul 21, 2010, at 23:03 , Eric Christopherson wrote:
>
> Finally, even though the 1.8.7 doc at
> http://ruby-doc.org/core-1.8.7/classes/File.html seems to describe the
> actual class, when I run ri File in Mac OS X using 1.8.7 I also get
> the spiel about ftools.rb instead of File per se.

Wow. So do I. That's worse than useless. I never use the ri docs myself. At some point or other, probably under OSX 10.4, I built a copy of Ruby 1.8.7, and put the HTML version of the documentation where I could find it, and I always reference my local files for documentation.

I cannot tell you any more which build of 1.8.7 I used, since I deleted the source directory some time after installing OSX 10.6. {shrug}



From: Charles Oliver Nutter on
On Wed, Jul 21, 2010 at 11:03 PM, Eric Christopherson
<echristopherson(a)gmail.com> wrote:
> Jruby 1.5 ri shows detailed information for File and IO, although
> again its page for File is about ftools.rb, and it doesn't say File <
> IO. I get this both on Windows and Mac OS X. Charles, you don't know
> where this is coming from??

I don't :(

We ship with a pregenerated set of ri docs from 1.8.7, and that's it.
Unfortunately ri/rdoc seems to be especially fragile in the context of
multiple source locations, so it's not clear whether we're doing
something wrong or whether it's just finding things in a different
order.

- Charlie