Class: CLI::PlayAgain
- Inherits:
-
Object
- Object
- CLI::PlayAgain
- Defined in:
- lib/ttt/interfaces/cli/lib/cli/play_again.rb
Instance Method Summary collapse
-
#initialize(presenter) ⇒ PlayAgain
constructor
A new instance of PlayAgain.
- #input ⇒ Object
- #play_again? ⇒ Boolean
- #play_again_msg ⇒ Object
- #process_reply(reply) ⇒ Object
- #valid_reply?(response) ⇒ Boolean
Constructor Details
#initialize(presenter) ⇒ PlayAgain
Returns a new instance of PlayAgain.
4 5 6 |
# File 'lib/ttt/interfaces/cli/lib/cli/play_again.rb', line 4 def initialize(presenter) self.presenter = presenter end |
Instance Method Details
#input ⇒ Object
23 24 25 |
# File 'lib/ttt/interfaces/cli/lib/cli/play_again.rb', line 23 def input presenter.input end |
#play_again? ⇒ Boolean
8 9 10 11 |
# File 'lib/ttt/interfaces/cli/lib/cli/play_again.rb', line 8 def play_again? play_again_msg process_reply input end |
#play_again_msg ⇒ Object
31 32 33 |
# File 'lib/ttt/interfaces/cli/lib/cli/play_again.rb', line 31 def play_again_msg presenter.play_again_msg end |
#process_reply(reply) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/ttt/interfaces/cli/lib/cli/play_again.rb', line 13 def process_reply reply if valid_reply?(reply) return false if reply.chomp == "n" true else presenter.error play_again? end end |
#valid_reply?(response) ⇒ Boolean
27 28 29 |
# File 'lib/ttt/interfaces/cli/lib/cli/play_again.rb', line 27 def valid_reply?(response) response =~ (/(y|n)/i) end |