class SimonGame
Attributes
attempt[RW]
number[RW]
Public Instance Methods
attempt_correct?()
click to toggle source
# File lib/adhearsion/generators/app/templates/simon_game.rb, line 39 def attempt_correct? @attempt == @number end
collect_attempt()
click to toggle source
# File lib/adhearsion/generators/app/templates/simon_game.rb, line 25 def collect_attempt result = ask @number, :limit => @number.length @attempt = result.response end
random_number()
click to toggle source
# File lib/adhearsion/generators/app/templates/simon_game.rb, line 17 def random_number rand(10).to_s end
reset()
click to toggle source
# File lib/adhearsion/generators/app/templates/simon_game.rb, line 43 def reset @attempt, @number = '', '' end
run()
click to toggle source
# File lib/adhearsion/generators/app/templates/simon_game.rb, line 7 def run answer reset loop do update_number collect_attempt verify_attempt end end
update_number()
click to toggle source
# File lib/adhearsion/generators/app/templates/simon_game.rb, line 21 def update_number @number << random_number end
verify_attempt()
click to toggle source
# File lib/adhearsion/generators/app/templates/simon_game.rb, line 30 def verify_attempt if attempt_correct? speak 'good' else speak "#{@number.length - 1} times wrong, try again smarty" reset end end