I’m having a hard time learning ruby

> My biggest hurdle getting started with ruby is finding which
> methods/classes/files to call upon for whatever the heck I'm trying to
> accomplish.

    However, if this is your only problem then you're probably a more
competent programmer than you let on. If that's the case, Paul's suggestion
of this reference will be valuable to you:

http://www.rubycentral.com/book/builtins.html

    It's not exactly searchable

It is if you wget it and can use grep fairly well. If you're on
Windows, you may need Cygwin or Windows-ports of those tools to get the
same behavior.

    I don't know if this is considered rude or not but, since the Pickaxe
book is available online at:

http://www.rubycentral.com/book/

    ...you could simply suck down the entire site and perform your search on
the HTML, all for free. Again, I don't know how the community feels about
you downloading the entire online "book," so my apologies if this is
considered rude...

Considering the Debian APT archives provide it in a .deb package for
easy "isntallation" on the local system (package name "rubybook"), I
doubt there's any cultural prohibition there. The online version is
licensed under the Open Publication License: so long as you don't
violate its terms, do what thou wilt.

···

On Fri, Aug 04, 2006 at 06:10:06AM +0900, Just Another Victim of the Ambient Morality wrote:

--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
Ben Franklin: "As we enjoy great Advantages from the Inventions of
others we should be glad of an Opportunity to serve others by any
Invention of ours, and this we should do freely and generously."

Oh, man, I got *so* tired of having to convert tabs to spaces in my editor before pasting them into irb!

On the other hand, with --noreadline, then I couldn't recall previous lines with the up-arrow. Also a horrible nuisance.

By purest serendipity, I discovered how to make irb not dump a directory listing (???) in the middle of a paste when it hit a tab character. It was buried near the end of the all-but-interminable manual page for the command line interface (bash).

I now have a new secret file in my home folder, one named .inputrc that contains this:

  set disable-completion on

Now irb and get along much better. :slight_smile:

···

On Aug 3, 2006, at 13:31, Bill Kelly wrote:

From: "Nate Imaqaguy" <breakingsoftware@gmail.com>

Someone told me about “.methods”, but that only works if you’re in an
irb session, which I find painful to use because I have to type all my
code in, line by line. I can’t even figure out how to paste each line
of the code I already have. Inevitably I fat finger something and get
mad.

On Windows, I've found running irb as:

irb --noreadline

can provide more hassle-free support for line editing / copy / paste and
command history in irb.

I have often typed a program in a text editor and then just pasted it
into an IRB window to play with dynamically. On Linux this is easy, on
windows you right-click on the IRB window's title-bar and go to
edit->paste.

If you installed on Windows and used the one-click installer, check
out Fxri - it's a "graphical" irb and ri all in one.

If you find yourself pasting your programs into IRB a lot, you'll also
want to look at the ruby-breakpoint library, which allows your program
to run and then "break out" into an IRB session right in the middle so
you can look at the variables and methods right there.

To try it, go to the prompt and:

  gem-install ruby-breakpoint

Then write your program:

require 'breakpoint'

....some code...
breakpoint
..some more code...

More info here: http://ruby-breakpoint.rubyforge.org/doc/

Les

···

On 8/3/06, Just Another Victim of the Ambient Morality <ihatespam@rogers.com> wrote:

"Nate Imaqaguy" <breakingsoftware@gmail.com> wrote in message

    The "methods" method works anywhere in Ruby but it is most useful in an
IRB session.
    I'm unsure why you want to type in your entire program into IRB. You
probably just want to type in relevant situations to test Ruby's behaviour,
such as operator precedence or regex behaviour.
    If you want to look at all the methods of a class, you simply need to
create an object of said class and call the "methods" method, perahps
followed by the "sort" method which can help you find what you're lookig
for..

Wow; lots of good stuff here. Thanks again everyone--much appreciated.

-nate

···

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

I especially like the idea of searching the digital books to
get the MSDN effect. I hadn't thought about that.

And as for method completion, I believe Komodo will do that
(www.activestate.com).

- Mark.

Also as you come from a Win32 background, rdoc (the tool used to
generate much of the API docs for Ruby), can create (if you have
HTMLHelp) chm files, which might feel very comfortable as well.

pth

···

On 8/3/06, Nate Imaqaguy <breakingsoftware@gmail.com> wrote:

Cool; thanks for all the feedback--excellent info.

I especially like the idea of searching the digital books to get the
MSDN effect. I hadn't thought about that.

-nate

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

Something else that helps with that is Google Desktop. It can index
PDF files so you can do a more fuzzy search than the strict one you
can do in Abobe Reader.

Though PDF's protected with DRM can probably defeat Google Desktop,
which is just another reason to be wary of them.

Les

···

On 8/3/06, Nate Imaqaguy <breakingsoftware@gmail.com> wrote:

Cool; thanks for all the feedback--excellent info.

I especially like the idea of searching the digital books to get the
MSDN effect. I hadn't thought about that.

+1

···

On Aug 3, 2006, at 4:44 PM, Matt Todd wrote:

But, really, with all of this frustration... it's better than the
frustrations just about anything else will give you... :slight_smile:

Yes. For my purposes, irb is a lot more convenient -- but it sure is a
clever bit of hackery, and I'm thoroughly impressed with it even if I
don't use it much.

···

On Fri, Aug 04, 2006 at 06:32:27AM +0900, Rob Sanheim wrote:

Have any of you tried why's "Try Ruby" ?

--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
"The first rule of magic is simple. Don't waste your time waving your
hands and hopping when a rock or a club will do." - McCloctnick the Lucid

Dave Howell wrote:

Nate Imaqaguy wrote:

For starters, just do you know where I’m coming from: I have little to no programming experience, except for some C and VB classes I took 6 years ago, which I did fine in.
My biggest hurdle getting started with ruby is finding which methods/classes/files to call upon for whatever the heck I’m trying to accomplish.

Well, I had years of experience in lots of languages when I started into Ruby, but my experience definitely did NOT include Java or C, which is taken for granted in a lot of documentation. "This works a lot like a C zingwanger, except you can modify it while it's running," and the like. Sigh.

Playing the guessing game of "if I were a command to do X, what would I call myself?" is something I still get to do a lot of. "Collect" and "index," (I'd never have guessed 'index' was a search function!) for arrays, and figuring out which of "chomp/chop/slice/split/strip" methods for strings I might want, were all non-obvious solutions to various problems I had when programming.

I think the 2nd Edition of Hal Fulton's _The Ruby Way_ is going to help with this problem. It's got more of a "here's a problem, how do you solve it with Ruby" orientation.

···

On Aug 3, 2006, at 12:55, Paul van Delst wrote:

As with any language (computer or natural), you won't become comfortable or fluent in the language until you have learned the vocabulary. Knowing how to conjugate a regular verb or the syntax of a method definition is not enough.

I know this sounds decidedly low-tech but I've found that the best way to become familiar with the vocabulary of a class library is to read through the documentation several times and then several more times.

Gary Wright

···

On Aug 3, 2006, at 5:28 PM, Dave Howell wrote:

Playing the guessing game of "if I were a command to do X, what would I call myself?" is something I still get to do a lot of. "Collect" and "index," (I'd never have guessed 'index' was a search function!) for arrays, and figuring out which of "chomp/chop/slice/split/strip" methods for strings I might want, were all non-obvious solutions to various problems I had when programming.