Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- creating a table of contents from user input
- =end
- STDOUT.sync = true
- puts "Table of Contents \n ===== == ======="
- books = []
- chapter = ''
- subject = ''
- page = ''
- input = ''
- while !input.match('x')
- puts "Enter \'Chapter No\', \'Subject Name\', \'Page No\' accordingly"
- chapter = gets.chomp
- subject = gets.chomp
- page = gets.chomp
- books << {'chapter' => chapter, 'subject'=>subject, 'page'=>page}
- puts "enter \'x\' to exit ENTER to continue"
- input = gets.chomp
- end
- books.each do |data|
- puts data.to_s + " "
- end
Add Comment
Please, Sign In to add comment