Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sockets - Maria #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
def get_the_vowel(word)
word.length > 1 && word =~ /[aeiou]/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very fancy! Could use a comment though!

end

puts "Please enter your first word"
first_word = gets.chomp.downcase
until get_the_vowel(first_word)
puts "Please enter a word with 2 or more characters and a vowel"
first_word = gets.chomp.downcase
end

words = []
a = first_word.rindex(/[aeiou].*/)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, would love a comment on this part. Most programmers don't choose to solve problems with regular expressions because they are hard to read on their own even if they are very efficient.

word_a = first_word[0...a]
words << word_a

puts "Please enter your second word"
second_word = gets.chomp.downcase
until get_the_vowel(second_word)
puts "Please enter a word with 2 or more characters and a vowel"
second_word = gets.chomp.downcase
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the indentation is conventionally done like this:

second_word = gets.chomp.downcase
until get_the_vowel(second_word)
  puts "Please enter a word with 2 or more characters and a vowel"
  second_word = gets.chomp.downcase
end 


b = second_word.split(/([aeiou].*)/)
word_b = b[1]
words << word_b

puts "Word #{word_a} + #{word_b} is #{words.join("")}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read our instructions carefully! We asked for a run_generator method that you didn't include!