Class: Codebreaker::Console
- Inherits:
-
Object
- Object
- Codebreaker::Console
- Includes:
- InputHelper, Phrases, Storage, Validator
- Defined in:
- lib/entities/console.rb
Constant Summary
Constants included from Validator
Validator::CB_ARRAY_SIZE, Validator::COMMANDS, Validator::GAME_NUMBER_RANGE, Validator::LEVELS, Validator::NAME_SIZE
Constants included from Storage
Instance Attribute Summary collapse
-
#game ⇒ Object
readonly
Returns the value of attribute game.
Instance Method Summary collapse
-
#initialize(name, complexity) ⇒ Console
constructor
A new instance of Console.
- #play ⇒ Object
Methods included from InputHelper
Methods included from Validator
Methods included from Storage
Methods included from Phrases
#about_complexities, #about_name, #empty_statistic, #error_massage, #goodbye, #greeting, #phrase_before_guess, #phrase_lose, #phrase_win, #puts_hint, #rules, #show, #zero_hint
Constructor Details
#initialize(name, complexity) ⇒ Console
Returns a new instance of Console.
10 11 12 |
# File 'lib/entities/console.rb', line 10 def initialize(name, complexity) @game = Game.new(name, complexity) end |
Instance Attribute Details
#game ⇒ Object (readonly)
Returns the value of attribute game.
4 5 6 |
# File 'lib/entities/console.rb', line 4 def game @game end |
Instance Method Details
#play ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/entities/console.rb', line 14 def play phrase_before_guess user_guess = user_input('guess') if user_guess == COMMANDS[:hint] show_hint else check_game_answer @game.guess user_guess end end |