Class: CodebreakerRuban::User
- Inherits:
-
Object
- Object
- CodebreakerRuban::User
- Includes:
- Validation
- Defined in:
- lib/app/entities/user.rb
Constant Summary collapse
- RANGE_NAME =
(3..20).freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ User
constructor
A new instance of User.
- #validate(name) ⇒ Object
Methods included from Validation
#check_number, #size, #validate_range_lenght
Constructor Details
#initialize(name) ⇒ User
Returns a new instance of User.
11 12 13 14 |
# File 'lib/app/entities/user.rb', line 11 def initialize(name) @name = name @errors = [] end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
6 7 8 |
# File 'lib/app/entities/user.rb', line 6 def errors @errors end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/app/entities/user.rb', line 7 def name @name end |
Instance Method Details
#validate(name) ⇒ Object
16 17 18 |
# File 'lib/app/entities/user.rb', line 16 def validate(name) return errors << Message.error_name_size(RANGE_NAME) unless size(name, RANGE_NAME) end |