Class: Codebreaker::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/codebreaker/console.rb

Constant Summary collapse

COMMAND =
{ start: '1', rules: '2', stats: '3', quit: 'q', use_tip: 'h', yes: 'y', no: 'n' }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gameObject (readonly)

Returns the value of attribute game.



6
7
8
# File 'lib/codebreaker/console.rb', line 6

def game
  @game
end

#userObject (readonly)

Returns the value of attribute user.



6
7
8
# File 'lib/codebreaker/console.rb', line 6

def user
  @user
end

Instance Method Details



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/codebreaker/console.rb', line 8

def menu
  show(:INTRO)
  loop do
    show(:MAIN_MENU, start: COMMAND[:start], rules: COMMAND[:rules], stats: COMMAND[:stats], quit: COMMAND[:quit])
    case input
    when COMMAND[:start] then pre_game_process
    when COMMAND[:rules] then show(:RULES)
    when COMMAND[:stats] then show_stats
    else show(:MENU_ERROR)
    end
  end
end