igpay-atinlay.rb
# Convert a sentence into Pig Latin
Convert a sentence into Pig Latin
Convert a sentence into Pig Latin
def to_pig_latin(word)
  was_capitalized = word == word.capitalize ? true : false
  letters = word.downcase[/\w+/]
  punctuation = word.gsub(/\w+/, "")
  first = letters.slice!(/\b\w*qu|\b[^aeiou]+/)
  letters.capitalize! if was_capitalized
  first ? letters + first + "ay" + punctuation : letters + "way" + punctuation
end
def to_pig_latin ( word ) was_capitalized = word == word . capitalize ? true : false letters = word . downcase [ / \w + / ] punctuation = word . gsub ( / \w + / , "" ) first = letters . slice! ( / \b \w *qu| \b [^aeiou]+ / ) letters . capitalize! if was_capitalized first ? letters + first + "ay" + punctuation : letters + "way" + punctuation end
Convert a sentence into Pig Latin
Convert a sentence into Pig Latin
word