Class: Codebreaker::User
- Inherits:
-
BaseEntity
- Object
- BaseEntity
- Codebreaker::User
- Defined in:
- lib/codebreaker/user.rb
Constant Summary collapse
- NAME_MIN_LENGTH =
3- NAME_MAX_LENGTH =
20
Instance Attribute Summary collapse
-
#difficulty ⇒ Object
readonly
Returns the value of attribute difficulty.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#used_attempts ⇒ Object
readonly
Returns the value of attribute used_attempts.
-
#used_hints ⇒ Object
readonly
Returns the value of attribute used_hints.
Instance Method Summary collapse
- #attempt ⇒ Object
- #attempts? ⇒ Boolean
- #hint ⇒ Object
- #hints? ⇒ Boolean
-
#initialize(name, difficulty) ⇒ User
constructor
A new instance of User.
Methods included from Validation
#valid_class?, #valid_non_empty_string?, #valid_non_negative_integer?, #valid_only_numeric_string?, #valid_positive_integer?, #valid_range?, #valid_string_max_length?, #valid_string_min_length?
Constructor Details
#initialize(name, difficulty) ⇒ User
Returns a new instance of User.
12 13 14 15 16 17 18 |
# File 'lib/codebreaker/user.rb', line 12 def initialize(name, difficulty) @name = name @difficulty = difficulty @used_attempts = 0 @used_hints = 0 super end |
Instance Attribute Details
#difficulty ⇒ Object (readonly)
Returns the value of attribute difficulty.
7 8 9 |
# File 'lib/codebreaker/user.rb', line 7 def difficulty @difficulty end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/codebreaker/user.rb', line 7 def name @name end |
#used_attempts ⇒ Object (readonly)
Returns the value of attribute used_attempts.
7 8 9 |
# File 'lib/codebreaker/user.rb', line 7 def used_attempts @used_attempts end |
#used_hints ⇒ Object (readonly)
Returns the value of attribute used_hints.
7 8 9 |
# File 'lib/codebreaker/user.rb', line 7 def used_hints @used_hints end |
Instance Method Details
#attempt ⇒ Object
32 33 34 |
# File 'lib/codebreaker/user.rb', line 32 def attempt @used_attempts += 1 end |
#attempts? ⇒ Boolean
24 25 26 |
# File 'lib/codebreaker/user.rb', line 24 def attempts? difficulty.attempts = used_attempts end |
#hint ⇒ Object
28 29 30 |
# File 'lib/codebreaker/user.rb', line 28 def hint @used_hints += 1 end |
#hints? ⇒ Boolean
20 21 22 |
# File 'lib/codebreaker/user.rb', line 20 def hints? difficulty.hints = used_hints end |