Class: CodebreakerGem::Console

Inherits:
Object
  • Object
show all
Includes:
ConsoleUserInteraction
Defined in:
lib/app/entities/console.rb

Constant Summary collapse

COMMANDS =
{
  start: 'start',
  rules: 'rules',
  stats: 'stats',
  exit: 'exit'
}.freeze
KEYWORDS =
{
  yes: 'yes',
  no: 'no'
}.freeze

Constants included from ConsoleUserInteraction

CodebreakerGem::ConsoleUserInteraction::ENTITIES

Instance Method Summary collapse

Methods included from ConsoleUserInteraction

#create_entity, #exit_from_console, #failing, #options_list, #output, #statistic, #user_input

Instance Method Details



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

def menu
  output.introduction
  loop do
    output.display(options_list)
    select_option
  end
end

#select_optionObject



27
28
29
30
31
32
33
34
# File 'lib/app/entities/console.rb', line 27

def select_option
  case user_input
  when COMMANDS[:start] then navigation
  when COMMANDS[:rules] then output.rules
  when COMMANDS[:stats] then output.display(statistic.rating_table)
  else failing.unexpected_option
  end
end