Class: Codebreaker::Entities::Menu

Inherits:
Object
  • Object
show all
Includes:
Modules::Validator
Defined in:
lib/codebreaker/entities/menu.rb

Constant Summary collapse

COMMANDS =
{
  start: 'start',
  exit: 'exit',
  rules: 'rules',
  stats: 'stats'
}.freeze
CHOOSE_COMMANDS =
{
  yes: 'yes'
}.freeze
HINT_COMMAND =
'hint'
MIN_SIZE_VALUE =
3
MAX_SIZE_VALUE =
20

Constants included from Modules::Validator

Modules::Validator::VALUE_FORMAT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Modules::Validator

#check_command_range, #check_emptyness, #check_length

Constructor Details

#initializeMenu

Returns a new instance of Menu.



22
23
24
25
26
27
# File 'lib/codebreaker/entities/menu.rb', line 22

def initialize
  @storage = DataStorage.new
  @renderer = Renderer.new
  @game = Game.new
  @statistics = Statistics.new
end

Instance Attribute Details

#gameObject (readonly)

Returns the value of attribute game.



7
8
9
# File 'lib/codebreaker/entities/menu.rb', line 7

def game
  @game
end

#guessObject (readonly)

Returns the value of attribute guess.



7
8
9
# File 'lib/codebreaker/entities/menu.rb', line 7

def guess
  @guess
end

#rendererObject (readonly)

Returns the value of attribute renderer.



7
8
9
# File 'lib/codebreaker/entities/menu.rb', line 7

def renderer
  @renderer
end

#storageObject (readonly)

Returns the value of attribute storage.



7
8
9
# File 'lib/codebreaker/entities/menu.rb', line 7

def storage
  @storage
end

Instance Method Details

#game_menuObject



29
30
31
32
33
# File 'lib/codebreaker/entities/menu.rb', line 29

def game_menu
  renderer.start_message

  choice_menu_process(ask(:choice_options, commands: COMMANDS.keys.join(' | ')))
end