Class: CodebreakerRuban::Console

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

Constant Summary collapse

OPTION =
{
  rules: 'rules',
  start: 'start',
  stats: 'stats',
  exit: 'exit'
}.freeze
HINT =
'hint'
WIN =
'++++'
YES =
%w[yes y].freeze
EASY_STRING =
'easy'
MEDIUM_STRING =
'medium'
HELL_STRING =
'hell'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConsole

Returns a new instance of Console.



20
21
22
# File 'lib/app/entities/console.rb', line 20

def initialize
  set_state(:choice_option)
end

Instance Attribute Details

#difficultyObject

Returns the value of attribute difficulty.



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

def difficulty
  @difficulty
end

#gameObject

Returns the value of attribute game.



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

def game
  @game
end

#stateObject

Returns the value of attribute state.



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

def state
  @state
end

#userObject

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
31
# File 'lib/app/entities/console.rb', line 24

def run
  Message.greeting
  loop do
    send(state)
    break if state == :game_over
  end
  Message.goodbye
end