Skip to content

Instantly share code, notes, and snippets.

Created September 7, 2014 00:39
Show Gist options
  • Save anonymous/7caf8b8f933e78dc72f6 to your computer and use it in GitHub Desktop.
Save anonymous/7caf8b8f933e78dc72f6 to your computer and use it in GitHub Desktop.
def vowels(any_string)
vowel = ["a","e","i","o","u"]
if vowel.include? any_string[0]
true
else
false
end
end
def first_letter(words)
words[0]
end
def first_two(words)
words[0..1]
end
def translate(any_string)
if vowels(any_string) == true && any_string.include?(" ")
any_string.map { |word| word + "ay " }
elsif vowels(any_string) == true
any_string + "ay"
elsif vowels(any_string) == false
any_string[1..-1] + first_letter + "ay"
end
end
error:
Failures:
1) #translate translates a word beginning with a consonant
Failure/Error: s = translate("banana")
ArgumentError:
wrong number of arguments (0 for 1)
# ./04_pig_latin/pig_latin.rb:10:in `first_letter'
# ./04_pig_latin/pig_latin.rb:26:in `translate'
# ./04_pig_latin/pig_latin_spec.rb:30:in `block (2 levels) in <top (required)>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment