Class: Codebreaker::Player
- Inherits:
-
Object
- Object
- Codebreaker::Player
- Includes:
- Validation
- Defined in:
- lib/entities/player.rb
Constant Summary collapse
- LENGTH_RANGE =
3..20
Instance Attribute Summary collapse
-
#errors_store ⇒ Object
Returns the value of attribute errors_store.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
Methods included from Validation
#valid_digits?, #valid_name?, #validate_in_range?, #validate_length, #validate_match, #validate_presence?
Instance Attribute Details
#errors_store ⇒ Object
Returns the value of attribute errors_store.
6 7 8 |
# File 'lib/entities/player.rb', line 6 def errors_store @errors_store end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/entities/player.rb', line 5 def name @name end |
Instance Method Details
#assign_name(name) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/entities/player.rb', line 10 def assign_name(name) @errors_store = [] return @name = name if validate_name(name) @errors_store << I18n.t(:when_wrong_name, min: LENGTH_RANGE.first, max: LENGTH_RANGE.last) end |
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/entities/player.rb', line 17 def valid? @errors_store.empty? end |