Skip to content

Instantly share code, notes, and snippets.

@RickArora

RickArora/.rb Secret

Created December 25, 2018 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RickArora/86ea3cfc8200315812d56df069966fe9 to your computer and use it in GitHub Desktop.
Save RickArora/86ea3cfc8200315812d56df069966fe9 to your computer and use it in GitHub Desktop.
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
@RickArora
Copy link
Author

  1. #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)>'

  2. #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)>'

  3. #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)>'

  4. #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)>'

  5. #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)>'

  6. #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)>'

  7. #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)>'

  8. #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)>'

  9. #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)>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment