Created
September 7, 2014 00:19
-
-
Save anonymous/9e9b085df79e53505773 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 + "ay".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 | |
here is the error message: | |
1) #translate translates a word beginning with a consonant | |
Failure/Error: s = translate("banana") | |
NoMethodError: | |
undefined method `any_string' for #<RSpec::ExampleGroups::Translate:0x007f8d0bae7c30> | |
# ./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