Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #table_of_contents.rb
- #tutorial for contents
- ls_chapter = []
- ls_page = []
- puts
- puts 'Welcome to Table of Contents maker'
- puts
- puts 'Type help for commands.'
- puts
- while gets.chomp != ''
- puts 'Enter your Chapter Title'
- in_chapter = gets.chomp
- ls_chapter.push in_chapter
- puts 'Enter your Page number: ie. Page 2'
- in_page = gets.chomp
- ls_page.push in_page
- end
- line_width = 40
- ls_chapter.each do |chap|
- ls_page.each do |page|
- puts "#{(chap.ljust(line_width))} #{(page.rjust(line_width))}"
- end
- end
Add Comment
Please, Sign In to add comment