Created
September 7, 2014 00:39
-
-
Save anonymous/7caf8b8f933e78dc72f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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