Class: Codebreaker::Console
- Inherits:
-
Object
- Object
- Codebreaker::Console
show all
- Includes:
- Database
- Defined in:
- lib/entities/console.rb
Constant Summary
collapse
- USER_ACTIONS =
{
start: 'start',
rules: 'rules',
stats: 'stats',
leave: 'exit'
}.freeze
- ACTIONS_FOR_DATABASE =
{
save_player: 'y'
}.freeze
Constants included
from Database
Database::FILE_PATH, Database::FOLDER_PATH, Database::FORMAT_PATH, Database::PATH
Instance Method Summary
collapse
Methods included from Database
#load_db, #save_to_db
Instance Method Details
#choose_action ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/entities/console.rb', line 14
def choose_action
respondent.show_message(:greeting)
loop do
respondent.show_message(:choose_action)
case input
when USER_ACTIONS[:start] then return process
when USER_ACTIONS[:rules] then rules.show_rules
when USER_ACTIONS[:stats] then show_statistics
else respondent.show_message(:wrong_input_action)
end
end
end
|
#show_statistics ⇒ Object
27
28
29
|
# File 'lib/entities/console.rb', line 27
def show_statistics
respondent.show(winners_load)
end
|
#winners_load ⇒ Object
31
32
33
|
# File 'lib/entities/console.rb', line 31
def winners_load
statistic.winners(load_db)
end
|