Guest User

Untitled

a guest
Jun 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. =begin
  2. creating a table of contents from user input
  3. =end
  4.  
  5. STDOUT.sync = true
  6.  
  7. puts "Table of Contents \n ===== == ======="
  8. books = []
  9.  
  10. chapter = ''
  11. subject = ''
  12. page = ''
  13. input = ''
  14. while !input.match('x')
  15. puts "Enter \'Chapter No\', \'Subject Name\', \'Page No\' accordingly"
  16. chapter = gets.chomp
  17. subject = gets.chomp
  18. page = gets.chomp
  19. books << {'chapter' => chapter, 'subject'=>subject, 'page'=>page}
  20. puts "enter \'x\' to exit ENTER to continue"
  21. input = gets.chomp
  22. end
  23.  
  24. books.each do |data|
  25. puts data.to_s + " "
  26. end
Add Comment
Please, Sign In to add comment