Sha256: cabae81fde9d43b3fd7a2c8c863c738925a049eeb07a37ae592bbae0ca2131d3
Contents?: true
Size: 725 Bytes
Versions: 3
Compression:
Stored size: 725 Bytes
Contents
# encoding: utf-8 class SimonGame < Adhearsion::CallController attr_accessor :number, :attempt def run answer reset say t(:hello) loop do update_number collect_attempt verify_attempt end end def random_number rand(10).to_s end def update_number @number << random_number end def collect_attempt result = ask @number, :limit => @number.length @attempt = result.utterance end def verify_attempt if attempt_correct? speak 'good' else speak "#{@number.length - 1} times wrong, try again smarty" reset end end def attempt_correct? @attempt == @number end def reset @attempt, @number = '', '' end end
Version data entries
3 entries across 3 versions & 1 rubygems