Created
November 23, 2013 02:07
-
-
Save jmoon90/7609880 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'pry' | |
| def playback(repeat) | |
| if repeat == "Nothing!" | |
| puts "Ok, fine!" | |
| elsif repeat == "I have a lot to say" | |
| lot_to_say | |
| else | |
| puts "You said: #{repeat}" | |
| end | |
| end | |
| def lot_to_say | |
| puts "Ok, let\'s hear it!" | |
| print "> " | |
| things_to_say = [] | |
| story = gets.chomp | |
| things_to_say << story | |
| while story != "done" | |
| print "> " | |
| story = gets.chomp | |
| break if story == "done" | |
| things_to_say << story | |
| end | |
| things_to_say.each_with_index do |message, index| | |
| if things_to_say.first == message | |
| puts "You said: #{message}" | |
| elsif things_to_say.last == message | |
| puts "Finally you said: #{message}" | |
| else | |
| puts "Then, you said: #{message}" | |
| end | |
| end | |
| puts "Phew! Glad you got all #{things_to_say.count} of those things off your chest!" | |
| end | |
| puts "What do you want to say?" | |
| print "> " | |
| playback(gets.chomp) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment