Class: CodebreakerGem::Player

Inherits:
ValidatedEntity show all
Defined in:
lib/app/entities/player.rb

Constant Summary collapse

NAME_LENGTH_RANGE =
(3..20).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ValidatedEntity

#failing, #valid?

Constructor Details

#initialize(name) ⇒ Player

Returns a new instance of Player.



9
10
11
12
# File 'lib/app/entities/player.rb', line 9

def initialize(name)
  super()
  @name = name
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



5
6
7
# File 'lib/app/entities/player.rb', line 5

def errors
  @errors
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/app/entities/player.rb', line 5

def name
  @name
end

Instance Method Details

#validateObject



14
15
16
# File 'lib/app/entities/player.rb', line 14

def validate
  @errors << failing.player_name_length unless check_name_length
end