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
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
#answer, #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
#interruptible_play, #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!
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
39 40 41 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 39 def attempt_correct? @attempt == @number end |
#collect_attempt ⇒ Object
25 26 27 28 |
# 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 ⇒ Object
17 18 19 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 17 def random_number rand(10).to_s end |
#reset ⇒ Object
43 44 45 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 43 def reset @attempt, @number = '', '' end |
#run ⇒ Object
7 8 9 10 11 12 13 14 15 |
# 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 ⇒ Object
21 22 23 |
# File 'lib/adhearsion/generators/app/templates/simon_game.rb', line 21 def update_number @number << random_number end |
#verify_attempt ⇒ Object
30 31 32 33 34 35 36 37 |
# 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 |