-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecho.rb
More file actions
34 lines (33 loc) · 816 Bytes
/
Copy pathecho.rb
File metadata and controls
34 lines (33 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def playback(say)
if say == "Nothing!"
return "Ok, fine!"
elsif say == "I have a lot to say"
puts "Ok, let's hear it!"
print "> "
say = gets.chomp
inputs = []
until say.downcase == "done"
inputs.push(say)
print "> "
say = gets.chomp
end
you_said = ""
inputs.each_with_index do |input, index|
if index == 0
prefix = "You said: "
elsif index == inputs.length - 1
prefix = "Finally you said: "
else
prefix = "Then, you said: "
end
you_said = you_said + prefix + input + "\n"
end
return you_said + "Phew! Glad you got all #{inputs.length} of those things off your chest!"
else
return "You said: #{say}"
end
end
puts "What do you want to say?"
print "> "
say = gets.chomp
puts playback(say)