Class: Codebreaker::Player

Inherits:
Object
  • Object
show all
Includes:
Mixins::Validator
Defined in:
lib/codebreaker/player.rb

Constant Summary collapse

NAME_SIZE =
{
  min: 3,
  max: 20
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Validator

#validate_length

Constructor Details

#initialize(name) ⇒ Player

Returns a new instance of Player.



12
13
14
# File 'lib/codebreaker/player.rb', line 12

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/codebreaker/player.rb', line 10

def name
  @name
end

Instance Method Details

#validateObject



16
17
18
# File 'lib/codebreaker/player.rb', line 16

def validate
  validate_length(@name, NAME_SIZE[:min], NAME_SIZE[:max])
end