Is rdoc (http://www.ruby-doc.org/core/) complete?

Hello Team,

Although I have over a dozen Ruby books (and still do not master the
language) I try to make frequent use of the online documentation, rdoc,
located at: http://www.ruby-doc.org/core/.
However, I was searching the *rdoc* for a method I new existed by reading "*The
Ruby Way* - Second Edition By: Hal" but could not find it. The method was *
find_all* which is part of *Array* class. I then looked a bit further and
noticed that a sizable number of methods for the same class are not found at
rdoc.

Since carrying books is a bit difficult a time, is there a definitive site,
book, or whatever where I can find all the docs for a given release of Ruby?

Thank you

Victor

find_all is not a method of the Array class, but an instance method of the
Enumerable module, which is mixed-in in class Array. If you look at the online
documentation for Array, you'll see that there's a section called "Included
Modules", which contains Enumerable. Clicking on it, you'll be directed to the
documentation for the Enumerable module, knowing that all its instance methods
are also instance methods of Array.

Stefano

···

On Thursday 22 May 2008, Victor Reyes wrote:

Hello Team,

Although I have over a dozen Ruby books (and still do not master the
language) I try to make frequent use of the online documentation, rdoc,
located at: http://www.ruby-doc.org/core/\.
However, I was searching the *rdoc* for a method I new existed by reading
"*The Ruby Way* - Second Edition By: Hal" but could not find it. The method
was * find_all* which is part of *Array* class. I then looked a bit further
and noticed that a sizable number of methods for the same class are not
found at rdoc.

Since carrying books is a bit difficult a time, is there a definitive site,
book, or whatever where I can find all the docs for a given release of
Ruby?

Thank you

Victor

[Note: parts of this message were removed to make it a legal post.]

Hello Team,

Although I have over a dozen Ruby books (and still do not master the
language) I try to make frequent use of the online documentation, rdoc,
located at:http://www.ruby-doc.org/core/\.
However, I was searching the *rdoc* for a method I new existed by reading "*The
Ruby Way* - Second Edition By: Hal" but could not find it. The method was *
find_all* which is part of *Array* class. I then looked a bit further and
noticed that a sizable number of methods for the same class are not found at
rdoc.

Since carrying books is a bit difficult a time, is there a definitive site,
book, or whatever where I can find all the docs for a given release of Ruby?

Thank you

Victor

···

On May 22, 5:30 pm, Victor Reyes <victor.re...@gmail.com> wrote:

Victor Reyes wrote:

The method was *find_all* which is part of *Array* class.

This method belongs in the Enumerable module, which Array included. Do
"ri find_all"

···

--
Posted via http://www.ruby-forum.com/\.

It's not easy for new user's to know where to look for such
information. I think it should be trivial for rdoc to reveal inherites/
included methods from other modules when searching for them in other
classes or modules that include them. IMHO, "ri Array#find_all" should
give a meaningful result since find_all is well-defined for Array
instances.

Lars

···

On May 22, 2:51 pm, Albert Schlef <albertsch...@gmail.com> wrote:

Victor Reyes wrote:
> The method was *find_all* which is part of *Array* class.

This method belongs in the Enumerable module, which Array included. Do
"ri find_all"

Please forgive my ignorance and thank you for the information.

I have an array of integers with a minimum of 9 elements and a maximum of
81.
I need to count the frequency of each digit (1..9).
That's why I was looking into the use of *find_all* or some other util that
would make my code simple. Otherwise I would have to loop and count the old
fashion way.

Thank you

Victor

···

On Thu, May 22, 2008 at 8:49 AM, Stefano Crocco <stefano.crocco@alice.it> wrote:

On Thursday 22 May 2008, Victor Reyes wrote:
> Hello Team,
>
> Although I have over a dozen Ruby books (and still do not master the
> language) I try to make frequent use of the online documentation, rdoc,
> located at: http://www.ruby-doc.org/core/\.
> However, I was searching the *rdoc* for a method I new existed by reading
> "*The Ruby Way* - Second Edition By: Hal" but could not find it. The
method
> was * find_all* which is part of *Array* class. I then looked a bit
further
> and noticed that a sizable number of methods for the same class are not
> found at rdoc.
>
> Since carrying books is a bit difficult a time, is there a definitive
site,
> book, or whatever where I can find all the docs for a given release of
> Ruby?
>
> Thank you
>
> Victor

find_all is not a method of the Array class, but an instance method of the
Enumerable module, which is mixed-in in class Array. If you look at the
online
documentation for Array, you'll see that there's a section called "Included
Modules", which contains Enumerable. Clicking on it, you'll be directed to
the
documentation for the Enumerable module, knowing that all its instance
methods
are also instance methods of Array.

Stefano

This is a typical way:

irb(main):001:0> a = [1,2,3,4,3,2,1,2,3,4,5,6,5,4,3,4,5,6,7,8,7,8,9]
=> [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 7, 8, 9]
irb(main):002:0> h = Hash.new {|h,k| h[k] = 0}
=> {}
irb(main):003:0> a.each {|x| h += 1}
=> [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 7, 8, 9]
irb(main):004:0> h
=> {5=>3, 6=>2, 1=>2, 7=>2, 2=>3, 8=>2, 3=>4, 9=>1, 4=>4}

or:

irb(main):005:0> h2 = Hash.new(0)
=> {}
irb(main):006:0> a.each {|x| h2 += 1}
=> [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 7, 8, 9]
irb(main):007:0> h2
=> {5=>3, 6=>2, 1=>2, 7=>2, 2=>3, 8=>2, 3=>4, 9=>1, 4=>4}

Jesus.

···

On Thu, May 22, 2008 at 3:11 PM, Victor Reyes <victor.reyes@gmail.com> wrote:

Please forgive my ignorance and thank you for the information.

I have an array of integers with a minimum of 9 elements and a maximum of
81.
I need to count the frequency of each digit (1..9).
That's why I was looking into the use of *find_all* or some other util that
would make my code simple. Otherwise I would have to loop and count the old
fashion way.

Thank you all.
Jesús, thank you for the code snippet.

···

On Thu, May 22, 2008 at 10:02 AM, Jesús Gabriel y Galán < jgabrielygalan@gmail.com> wrote:

On Thu, May 22, 2008 at 3:11 PM, Victor Reyes <victor.reyes@gmail.com> > wrote:
> Please forgive my ignorance and thank you for the information.
>
> I have an array of integers with a minimum of 9 elements and a maximum of
> 81.
> I need to count the frequency of each digit (1..9).
> That's why I was looking into the use of *find_all* or some other util
that
> would make my code simple. Otherwise I would have to loop and count the
old
> fashion way.
>

This is a typical way:

irb(main):001:0> a = [1,2,3,4,3,2,1,2,3,4,5,6,5,4,3,4,5,6,7,8,7,8,9]
=> [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 7, 8, 9]
irb(main):002:0> h = Hash.new {|h,k| h[k] = 0}
=> {}
irb(main):003:0> a.each {|x| h += 1}
=> [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 7, 8, 9]
irb(main):004:0> h
=> {5=>3, 6=>2, 1=>2, 7=>2, 2=>3, 8=>2, 3=>4, 9=>1, 4=>4}

or:

irb(main):005:0> h2 = Hash.new(0)
=> {}
irb(main):006:0> a.each {|x| h2 += 1}
=> [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 7, 8, 9]
irb(main):007:0> h2
=> {5=>3, 6=>2, 1=>2, 7=>2, 2=>3, 8=>2, 3=>4, 9=>1, 4=>4}

Jesus.

#thank you for the code snippet.

also try ruby1.8.7 or ruby1.9

036:0> a
=> [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 7, 8, 9]

037:0> a.group_by{|k| k }.inject({}){|h,(k,v)| h[k] = v.size; h }
=> {1=>2, 2=>3, 3=>4, 4=>4, 5=>3, 6=>2, 7=>2, 8=>2, 9=>1}

···

From: Victor Reyes [mailto:victor.reyes@gmail.com]

The beauty of Ruby!
Many and elegant ways to solve a problem!

Thanks guys!

Victor

···

On Thu, May 22, 2008 at 10:21 PM, Peña, Botp <botp@delmonte-phil.com> wrote:

From: Victor Reyes [mailto:victor.reyes@gmail.com]
#thank you for the code snippet.

also try ruby1.8.7 or ruby1.9

036:0> a
=> [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 7, 8, 9]

037:0> a.group_by{|k| k }.inject({}){|h,(k,v)| h[k] = v.size; h }
=> {1=>2, 2=>3, 3=>4, 4=>4, 5=>3, 6=>2, 7=>2, 8=>2, 9=>1}