Class: Console

Inherits:
Object
  • Object
show all
Includes:
Codebreaker, Database, Output
Defined in:
lib/console_app/console.rb

Constant Summary collapse

COMMANDS =
{
  start: 'start',
  rules: 'rules',
  stats: 'stats',
  exit: 'exit',
  hints: 'hints'
}.freeze
YES =
'y'.freeze

Constants included from Codebreaker

Codebreaker::VERSION

Constants included from Codebreaker::Validation

Codebreaker::Validation::VALID_DIFFICULTS

Instance Method Summary collapse

Methods included from Codebreaker::Validation

#difficult_valid?, #guess_valid?, #name_valid?

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/console_app/console.rb', line 16

def run
  Messages.show_greeting

  loop do
    case gets.chomp.downcase
    when COMMANDS[:start] then return register
    when COMMANDS[:rules] then Messages.show_rules
    when COMMANDS[:stats] then Statistics.show
    when COMMANDS[:exit] then close
    else Messages.unknown_command
    end
  end
end