Class: CodebreakerKirill::User
- Inherits:
-
Object
- Object
- CodebreakerKirill::User
- Includes:
- Settings
- Defined in:
- lib/codebreaker_kirill/user.rb
Constant Summary
Constants included from Settings
Settings::CODE_LENGTH, Settings::DIFFICULTY, Settings::GUESS_LENGTH, Settings::NAME_MAX_LENGTH, Settings::NAME_MIN_LENGTH, Settings::NEGATIVE_RESPONSE, Settings::POSITIVE_RESPONSE, Settings::RANDOM_RANGE
Instance Attribute Summary collapse
-
#attempts_used ⇒ Object
Returns the value of attribute attempts_used.
-
#difficulty ⇒ Object
readonly
Returns the value of attribute difficulty.
-
#hints_used ⇒ Object
Returns the value of attribute hints_used.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, difficulty) ⇒ User
constructor
A new instance of User.
- #validation(name, difficulty) ⇒ Object
Constructor Details
#initialize(name, difficulty) ⇒ User
Returns a new instance of User.
10 11 12 13 14 15 16 17 |
# File 'lib/codebreaker_kirill/user.rb', line 10 def initialize(name, difficulty) validation(name, difficulty) @difficulty = difficulty @name = name @level = Settings::DIFFICULTY[@difficulty] @attempts_used = 0 @hints_used = 0 end |
Instance Attribute Details
#attempts_used ⇒ Object
Returns the value of attribute attempts_used.
7 8 9 |
# File 'lib/codebreaker_kirill/user.rb', line 7 def attempts_used @attempts_used end |
#difficulty ⇒ Object (readonly)
Returns the value of attribute difficulty.
8 9 10 |
# File 'lib/codebreaker_kirill/user.rb', line 8 def difficulty @difficulty end |
#hints_used ⇒ Object
Returns the value of attribute hints_used.
7 8 9 |
# File 'lib/codebreaker_kirill/user.rb', line 7 def hints_used @hints_used end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
8 9 10 |
# File 'lib/codebreaker_kirill/user.rb', line 8 def level @level end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/codebreaker_kirill/user.rb', line 8 def name @name end |
Instance Method Details
#validation(name, difficulty) ⇒ Object
19 20 21 22 |
# File 'lib/codebreaker_kirill/user.rb', line 19 def validation(name, difficulty) Validations.validate_name(name) Validations.validate_difficulty(difficulty) end |