Class: SimonGame
- Inherits:
-
Adhearsion::CallController
- Object
- Adhearsion::CallController
- SimonGame
- Defined in:
- lib/adhearsion/generators/app/templates/simon_game.rb
Constant Summary
Constants included from Adhearsion::CallController::Record
Adhearsion::CallController::Record::RecordError
Constants included from Adhearsion::CallController::Output
Adhearsion::CallController::Output::NoDocError, Adhearsion::CallController::Output::PlaybackError
Constants included from Adhearsion::CallController::Input
Adhearsion::CallController::Input::InputError
Instance Attribute Summary collapse
-
#attempt ⇒ Object
Returns the value of attribute attempt.
-
#number ⇒ Object
Returns the value of attribute number.
Attributes inherited from Adhearsion::CallController
Instance Method Summary collapse
- #attempt_correct? ⇒ Boolean
- #collect_attempt ⇒ Object
- #random_number ⇒ Object
- #reset ⇒ Object
- #run ⇒ Object
- #update_number ⇒ Object
- #verify_attempt ⇒ Object
Methods inherited from Adhearsion::CallController
after_call, #answer, before_call, #bg_exec, #eql?, exec, #exec, #exec_with_callback, #hangup, #hard_pass, #initialize, #invoke, #join, #logger, #method_missing, mixin, #mute, #pass, #redirect, #reject, #stop_all_components, #unmute
Methods included from Adhearsion::CallController::Record
Methods included from Adhearsion::CallController::Output
#locale, #locale=, #output_formatter, #play, #play!, #play_audio, #play_audio!, #play_document, #play_document!, #play_numeric, #play_numeric!, #play_time, #play_time!, #say, #say!, #say_characters, #say_characters!, #t
Methods included from Adhearsion::CallController::Input
Methods included from Adhearsion::CallController::Dial
Constructor Details
This class inherits a constructor from Adhearsion::CallController
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Adhearsion::CallController
Instance Attribute Details
#attempt ⇒ Object
Returns the value of attribute attempt.
5 6 7 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 5 def attempt @attempt end |
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 5 def number @number end |
Instance Method Details
#attempt_correct? ⇒ Boolean
40 41 42 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 40 def attempt_correct? @attempt == @number end |
#collect_attempt ⇒ Object
26 27 28 29 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 26 def collect_attempt result = ask @number, :limit => @number.length @attempt = result.utterance end |
#random_number ⇒ Object
18 19 20 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 18 def random_number rand(10).to_s end |
#reset ⇒ Object
44 45 46 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 44 def reset @attempt, @number = '', '' end |
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 7 def run answer reset say t(:hello) loop do update_number collect_attempt verify_attempt end end |
#update_number ⇒ Object
22 23 24 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 22 def update_number @number << random_number end |
#verify_attempt ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 31 def verify_attempt if attempt_correct? speak 'good' else speak "#{@number.length - 1} times wrong, try again smarty" reset end end |