Skip to content

Instantly share code, notes, and snippets.

@jmoon90
Last active December 29, 2015 05:29
Show Gist options
  • Select an option

  • Save jmoon90/7622456 to your computer and use it in GitHub Desktop.

Select an option

Save jmoon90/7622456 to your computer and use it in GitHub Desktop.
def playback(repeat)
if repeat == "Nothing!"
puts "Ok, fine!"
elsif repeat == "I have a lot to say"
puts "Ok, let\'s hear it!"
print "> "
lot_to_say
out_put_format(things_to_say)
elsif repeat == "I have something prepared"
puts "Ok, where can I find what you want to say?"
print "> "
text_file = gets.chomp
puts "Loading #{text_file}..."
while File.exist?(text_file) == false
puts "I couldn't find that file."
puts "Where can I find what you want to say?"
print "> "
text_file = gets.chomp
puts "Loading #{text_file}..."
end
if File.exist?(text_file)
out_put = prepared(text_file)
out_put_format(out_put)
end
else
puts "You said: #{repeat}"
end
end
def lot_to_say
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
end
def out_put_format(array)
array.each_with_index do |message, index|
if array.first == message
puts "You said: #{message}"
elsif array.last == message
puts "Finally you said: #{message}"
else
puts "Then, you said: #{message}"
end
end
puts "Phew! Glad you got all #{array.count} of those things off your chest!"
end
def prepared(file)
array = []
File.open(file, "r").each_line do |line|
array << line
end
array
end
puts "What do you want to say?"
print "> "
playback(gets.chomp)
We're leaving ground
Will things ever be the same again?
It's the final countdown
The final countdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment