Class: PlayerName
Overview
Class to model a player’s name given as an answer
Instance Attribute Summary collapse
-
#answer ⇒ Object
readonly
Returns the value of attribute answer.
Attributes inherited from Answer
Instance Method Summary collapse
-
#initialize(answer) ⇒ PlayerName
constructor
A new instance of PlayerName.
- #valid? ⇒ Boolean
Methods inherited from Answer
Constructor Details
#initialize(answer) ⇒ PlayerName
Returns a new instance of PlayerName.
9 10 11 12 |
# File 'lib/player_name.rb', line 9 def initialize(answer) super(answer) valid? end |
Instance Attribute Details
#answer ⇒ Object (readonly)
Returns the value of attribute answer.
7 8 9 |
# File 'lib/player_name.rb', line 7 def answer @answer end |
Instance Method Details
#valid? ⇒ Boolean
14 15 16 17 18 |
# File 'lib/player_name.rb', line 14 def valid? self.errors = [] errors << 'Name must be between 3 - 12 chars.' unless valid_size? errors.empty? end |