[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

Victor Reyes

5/22/2008 12:31:00 PM

[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....
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

9 Answers

Rachel

5/22/2008 12:46:00 PM

0

On May 22, 5:30 pm, Victor Reyes <victor.re...@gmail.com> wrote:
> [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....
> 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

Stefano Crocco

5/22/2008 12:49:00 PM

0

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....
> 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


Albert Schlef

5/22/2008 12:52:00 PM

0

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-....

Lars Christensen

5/22/2008 1:08:00 PM

0

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"

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

Victor Reyes

5/22/2008 1:11:00 PM

0

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

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....
> > 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
>
>
>

Jesús Gabriel y Galán

5/22/2008 2:02:00 PM

0

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[x] += 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[x] += 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.

Victor Reyes

5/22/2008 4:28:00 PM

0

Thank you all.
Jes=FAs, thank you for the code snippet.

On Thu, May 22, 2008 at 10:02 AM, Jes=FAs Gabriel y Gal=E1n <
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 =3D [1,2,3,4,3,2,1,2,3,4,5,6,5,4,3,4,5,6,7,8,7,8,9]
> =3D> [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 =3D Hash.new {|h,k| h[k] =3D 0}
> =3D> {}
> irb(main):003:0> a.each {|x| h[x] +=3D 1}
> =3D> [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
> =3D> {5=3D>3, 6=3D>2, 1=3D>2, 7=3D>2, 2=3D>3, 8=3D>2, 3=3D>4, 9=3D>1, 4=
=3D>4}
>
> or:
>
> irb(main):005:0> h2 =3D Hash.new(0)
> =3D> {}
> irb(main):006:0> a.each {|x| h2[x] +=3D 1}
> =3D> [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
> =3D> {5=3D>3, 6=3D>2, 1=3D>2, 7=3D>2, 2=3D>3, 8=3D>2, 3=3D>4, 9=3D>1, 4=
=3D>4}
>
>
>
> Jesus.
>
>

Peña, Botp

5/23/2008 2:21:00 AM

0

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

also try ruby1.8.7 or ruby1.9

036:0> a
=3D> [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] =3D v.size; h }
=3D> {1=3D>2, 2=3D>3, 3=3D>4, 4=3D>4, 5=3D>3, 6=3D>2, 7=3D>2, 8=3D>2, =
9=3D>1}

Victor Reyes

5/23/2008 5:13:00 PM

0

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=F1a, Botp <botp@delmonte-phil.com> wro=
te:

> 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
> =3D> [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] =3D v.size; h }
> =3D> {1=3D>2, 2=3D>3, 3=3D>4, 4=3D>4, 5=3D>3, 6=3D>2, 7=3D>2, 8=3D>2, 9=
=3D>1}
>
>