Hopefully it was a beginners mistake and not a pattern of my own logic :)
Thanks Robert!

Stuart


On 6/24/06, Robert Klemme <shortcutter / googlemail.com> wrote:
> 2006/6/24, Dark Ambient <sambient / gmail.com>:
> > Trying to do some fancy formatting and getting an error message.
> > Since I know .center is a method the error message can't be the
> > ultimate truth.  Anyone ?
>
> I'm not sure what you're implying here, but as the error message
> indicates Array#center is nonexistent.  You probably want
> String#center as in
>
> irb(main):002:0> "fff".center 10
> => "   fff    "
>
> You also probably missed a toc there:
>
> >                           Table of Contents    <------This is corect
> > toc.rb:8: undefined method `center' for [2]:Array (NoMethodError)
> > >Exit code: 1
> >
> > toc = ['Table of Contents', 'Chapter 1', 'Getting Started',
> >         'page 1', 'Chapter 2', 'Numbers', 'page 9',
> >         'Chapter 3', 'Letter', 'page 13']
> >
> >         line_width = 70
> >
> >         puts(              toc[0].center(line_width))
> >         puts(              toc[1].ljust(line_width/2) +
> > [2].center(line_width) +[3].rjust(line_width/2))
>    ^^^
>
> "toc" missing here.
>
> >         puts(              toc[4][5][6])
> >         puts(              toc[7][8][9])
> >
> Cheers
>
> robert
>
> --
> Have a look: http://www.flickr.com/photos/fussel-foto/
>
>