Class: CodebreakerRostik::Console
- Inherits:
-
Object
- Object
- CodebreakerRostik::Console
- Includes:
- ConsoleHelpers, Validator
- Defined in:
- lib/console.rb
Constant Summary collapse
- OPTIONS =
{ start: 'Start', rules: 'Rules', stats: 'Stats', exit: 'Exit' }.freeze
- GAME_RESULTS =
{ win: '++++', lose: '----' }.freeze
- NAME_DIFFICULTIES =
%w[Easy Medium Hell].freeze
- COUNT_ATTEMPTS =
0
- COUNT_HINTS =
0
- ANSWERS =
{ yes: 'Yes' }.freeze
- NAME_LENGTH_RANGE =
(3..20).freeze
- HINT =
'Hint'.freeze
- EXIT =
'Exit'.freeze
Instance Attribute Summary collapse
-
#info_difficult ⇒ Object
readonly
Returns the value of attribute info_difficult.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#user_name ⇒ Object
readonly
Returns the value of attribute user_name.
Instance Method Summary collapse
Methods included from Validator
#valid_length?, #validate_class?, #validate_each_char_in_range?, #validate_length_range?
Methods included from ConsoleHelpers
Instance Attribute Details
#info_difficult ⇒ Object (readonly)
Returns the value of attribute info_difficult.
6 7 8 |
# File 'lib/console.rb', line 6 def info_difficult @info_difficult end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'lib/console.rb', line 6 def user @user end |
#user_name ⇒ Object (readonly)
Returns the value of attribute user_name.
6 7 8 |
# File 'lib/console.rb', line 6 def user_name @user_name end |
Instance Method Details
#check_option ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/console.rb', line 28 def check_option show_info(:welcome) loop do case (:choose_option) when OPTIONS[:start] then return registration when OPTIONS[:rules] then show_rules when OPTIONS[:stats] then show_stats else show_info(:wrong_input_option) end end end |
#show_message_with_input(message, key = nil) ⇒ Object
41 42 43 44 45 |
# File 'lib/console.rb', line 41 def (, key = nil) show_info(, key) value = gets.chomp.capitalize value == OPTIONS[:exit] ? bye : value end |