-
-
Save RickArora/86ea3cfc8200315812d56df069966fe9 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 translate(translate_this) | |
translated_word = "" | |
translate_this.split.each do |word| | |
if (word[0] == "a" || word[0] == "i" || word[0] == "o" || word = "u" || word = "e") | |
translated_word = translated_word + word + "ay " | |
else | |
translated_word = translated_word + word[1..word.length-1] + word[0] + "ay " | |
end | |
end | |
return translated_word[0..word.length-2] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#translate translates a word beginning with a vowel
Failure/Error: s = translate("apple")
NameError:
undefined local variable or method `word' for #RSpec::ExampleGroups::Translate:0x00007fda57b49838
./lib/04_pig_latin.rb:10:in `translate'
./spec/04_pig_latin_spec.rb:28:in `block (2 levels) in <top (required)>'
#translate translates a word beginning with a consonant
Failure/Error: s = translate("banana")
NameError:
undefined local variable or method `word' for #RSpec::ExampleGroups::Translate:0x00007fda57b17d38
./lib/04_pig_latin.rb:10:in `translate'
./spec/04_pig_latin_spec.rb:33:in `block (2 levels) in <top (required)>'
#translate translates a word beginning with two consonants
Failure/Error: s = translate("cherry")
NameError:
undefined local variable or method `word' for #RSpec::ExampleGroups::Translate:0x00007fda57b16f28
./lib/04_pig_latin.rb:10:in `translate'
./spec/04_pig_latin_spec.rb:38:in `block (2 levels) in <top (required)>'
#translate translates two words
Failure/Error: s = translate("eat pie")
NameError:
undefined local variable or method `word' for #RSpec::ExampleGroups::Translate:0x00007fda57b15448
./lib/04_pig_latin.rb:10:in `translate'
./spec/04_pig_latin_spec.rb:43:in `block (2 levels) in <top (required)>'
#translate translates a word beginning with three consonants
Failure/Error: expect(translate("three")).to eq("eethray")
NameError:
undefined local variable or method `word' for #RSpec::ExampleGroups::Translate:0x00007fda57b43618
./lib/04_pig_latin.rb:10:in `translate'
./spec/04_pig_latin_spec.rb:48:in `block (2 levels) in <top (required)>'
#translate counts 'sch' as a single phoneme
Failure/Error: s = translate("school")
NameError:
undefined local variable or method `word' for #RSpec::ExampleGroups::Translate:0x00007fda57b41fc0
./lib/04_pig_latin.rb:10:in `translate'
./spec/04_pig_latin_spec.rb:52:in `block (2 levels) in <top (required)>'
#translate counts 'qu' as a single phoneme
Failure/Error: s = translate("quiet")
NameError:
undefined local variable or method `word' for #RSpec::ExampleGroups::Translate:0x00007fda57b966b0
./lib/04_pig_latin.rb:10:in `translate'
./spec/04_pig_latin_spec.rb:57:in `block (2 levels) in <top (required)>'
#translate counts 'qu' as a consonant even when it's preceded by a consonant
Failure/Error: s = translate("square")
NameError:
undefined local variable or method `word' for #RSpec::ExampleGroups::Translate:0x00007fda57b87110
./lib/04_pig_latin.rb:10:in `translate'
./spec/04_pig_latin_spec.rb:62:in `block (2 levels) in <top (required)>'
#translate translates many words
Failure/Error: s = translate("the quick brown fox")
NameError:
undefined local variable or method `word' for #RSpec::ExampleGroups::Translate:0x00007fda57b856f8
./lib/04_pig_latin.rb:10:in `translate'
./spec/04_pig_latin_spec.rb:67:in `block (2 levels) in <top (required)>'