forked from Ada-C11/portmanteau-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenrator.rb
63 lines (54 loc) · 1.1 KB
/
genrator.rb
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def is_vowel?(letter)
case letter
when "a", "e", "i", "o", "u"
return true
else
return false
end
end
def run_generator
puts "Input the first word:"
word_a = gets.chomp.downcase
while word_a.length <= 1
puts "Please enter a word that has more than 1 letter:"
word_a = gets.chomp.downcase
end
puts "Input the second word:"
word_b = gets.chomp.downcase
while word_b.length <= 1
puts "Please enter a word that has more than 1 letter:"
word_b = gets.chomp.downcase
end
port_a = word_a
port_b = word_b
port_a.reverse.each_char do |c|
if is_vowel?(c) == false
port_a = port_a.chop
else
port_a = port_a.chop
break
end
end
if port_a == ""
port_a = word_a
end
port_b.each_char do |c|
if is_vowel?(c) == false
port_b = port_b[1..-1]
else
break
end
end
if port_b == ""
port_b = word_b
end
puts port_a + port_b
puts "Would you like to try again?! Enter 'Y' or 'N'"
answer = gets.chomp.upcase
if answer == "Y"
run_generator
else
puts "Thanks for playing!"
end
end
run_generator