Class: Menu

Inherits:
Object
  • Object
show all
Includes:
Validator
Defined in:
lib/app/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 Validator

Validator::VALUE_FORMAT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validator

#check_command_range, #check_emptyness, #check_length

Constructor Details

#initializeMenu

Returns a new instance of Menu.



20
21
22
23
24
25
# File 'lib/app/entities/menu.rb', line 20

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.



5
6
7
# File 'lib/app/entities/menu.rb', line 5

def game
  @game
end

#guessObject (readonly)

Returns the value of attribute guess.



5
6
7
# File 'lib/app/entities/menu.rb', line 5

def guess
  @guess
end

#rendererObject (readonly)

Returns the value of attribute renderer.



5
6
7
# File 'lib/app/entities/menu.rb', line 5

def renderer
  @renderer
end

#storageObject (readonly)

Returns the value of attribute storage.



5
6
7
# File 'lib/app/entities/menu.rb', line 5

def storage
  @storage
end

Instance Method Details

#game_menuObject



27
28
29
30
# File 'lib/app/entities/menu.rb', line 27

def game_menu
  renderer.start_message
  choice_menu_process(ask(:choice_options, commands: COMMANDS.keys.join(' | ')))
end