Auto indentation problem; little help please :)

Hi,

I’m new to ruby and irb and am hoping someone can give me a helping
hand. Even this issue is small, it’s annoying to me.

I’m running irb 0.9.5 on OS X 10.4 within an iterm terminal. I’m doing
all this on a MacBook Pro laptop.

I’ve got auto-indenting set and readline support.

The annoying indent problem is, when I type code into irb, it indents as
follows:


gary-churchs-computer:~ gary$ irb
irb(main):001:0> class Song
irb(main):002:1> def initialize(name, artist, duration)
irb(main):003:2> @name = name
irb(main):004:2> @artist = artist
irb(main):005:2> @duration = duration
irb(main):006:2> end
irb(main):007:1> end
=> nil
irb(main):008:0>

with the “end”'s not lining up below the correct upper lines (here “def”
and “class”, respectively.) In all the examples I’ve seen in the book,
everything (including comments) line up correctly.

When I type in the code, at the end of a line, I simply hit “return” to
get to the next line.

Any ideas for this minor buy annoying problem?

Thanks much,
Gary

Gary Church wrote:

Hi,

I’ve got auto-indenting set and readline support.

with the “end”'s not lining up below the correct upper lines (here “def”
and “class”, respectively.) In all the examples I’ve seen in the book,
everything (including comments) line up correctly.

It is not really possible to do because irb does not know
when you are going to end a block. Once you have entered
the end, the only way to get it to line up right would
be to use terminal controls through Curses or something
and it probably is not worth the trouble.

I would recommend to just try to ignore it or, if you
want, turn autoindent off and enter the whitespace
yourself :slight_smile:

Thanks much,
Gary

Eero S. wrote:

It is not really possible to do because irb does not know
when you are going to end a block. Once you have entered
the end, the only way to get it to line up right would
be to use terminal controls through Curses or something
and it probably is not worth the trouble.

I would recommend to just try to ignore it or, if you
want, turn autoindent off and enter the whitespace
yourself :slight_smile:

Thanks for the reply.

Seemed that way to me too but I’ve seen many examples in
books and on the net where, apparently, auto-indent was on
and the “end” 's lined up properly. Seemed strange to me and
that prompted the post.

Thanks again,
Gary.