Class: Codebreaker::Console

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

Constant Summary collapse

HINT =
'-h'.freeze
YES =
'y'.freeze
EMPTY_INPUT =
''.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(game = DEMO) ⇒ Console

Returns a new instance of Console.



14
15
16
17
18
# File 'lib/codebreaker/console.rb', line 14

def initialize(game = DEMO)
  @locale = Localization.new(:console)
  load_console(game)
  start_game if game == DEMO
end

Instance Attribute Details

#gameObject (readonly)

Returns the value of attribute game.



12
13
14
# File 'lib/codebreaker/console.rb', line 12

def game
  @game
end

#scoresObject (readonly)

Returns the value of attribute scores.



12
13
14
# File 'lib/codebreaker/console.rb', line 12

def scores
  @scores
end

#storage_pathObject (readonly)

Returns the value of attribute storage_path.



12
13
14
# File 'lib/codebreaker/console.rb', line 12

def storage_path
  @storage_path
end

Instance Method Details

#erase_scoresObject



26
27
28
29
30
# File 'lib/codebreaker/console.rb', line 26

def erase_scores
  print message['alerts']['erase_scores']
  erase_game_data if input_selector
  exit_console
end

#start_gameObject



20
21
22
23
24
# File 'lib/codebreaker/console.rb', line 20

def start_game
  puts message['alerts']['welcome'].colorize(:background => :blue)
  puts message['alerts']['hint_info']
  submit_answer
end