Hello people!
I am very new to Ruby. Yesterday I bought very nice book about Ruby and
immediately started learning. Now I have little problem :)
The exercise is to display text like this:


                Table of Contents

Chapter 1: Getting Started              page 1
Chapter 2: Numbers                      page 9
Chapter 3: Letters                      page 13


but my text always looks like this:

                Table of Contents


Chapter 1: Getting Started              page 1
Chapter 2: Numbers                    page 9
Chapter 3: Letters                  page 13


My code is:
--------------------------------------------------------------------
line_width = 50
str1 = 'Table of Contents'
str_chap1 = 'Chapter 1:   Getting Started'
str_chap2 = 'Chapter 2:   Numbers'
str_chap3 = 'Chapter 3:   Letters'

str_page1 = 'page 1'
str_page9 = 'page 9'
str_page13 = 'page 13'

puts(str1.center(line_width))
puts''
puts(str_chap1.ljust(line_width/2) + str_page1.rjust(line_width/2))
puts(str_chap2.ljust(line_width/2) + str_page9.rjust(line_width/2))
puts(str_chap3.ljust(line_width/2) + str_page13.rjust(line_width/2))
--------------------------------------------------------------------

What should I do to vertically align strings )'page 1', 'page 9' and
'page 13')?

P.S. If you know some more better way to write this, I would be happy to
see it (and to try to understand it :) )
P.S. Sory if this is a stuped question.

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