Skip to content

Instantly share code, notes, and snippets.

@mikelbring
Created February 28, 2013 18:06
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 mikelbring/5058786 to your computer and use it in GitHub Desktop.
Save mikelbring/5058786 to your computer and use it in GitHub Desktop.
class LearnMyABCs
def initialize
@letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
end
def speak(text)
puts text
system 'say ' + text
end
def type_letter(letter)
self.speak('Please type the letter ' + letter)
input = gets.chomp
# to prevent rapid enter pressing - darn kids
until input[0] != nil
input = gets.chomp
end
# just get the first letter, incase of multiple letter inputs
if input[0,1].upcase == letter
self.speak('Good Job')
else
speak('Try again')
self.type_letter letter
end
end
def start()
for letter in @letters.shuffle
self.type_letter letter
end
speak('Nice work, you went through the entire alphabeta.');
end
end
LearnMyABCs.new.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment