Class: FootballManager::Player
- Inherits:
-
Object
- Object
- FootballManager::Player
- Defined in:
- lib/football-manager/player.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#skill ⇒ Object
Returns the value of attribute skill.
Instance Method Summary collapse
-
#initialize(name, skill) ⇒ Player
constructor
A new instance of Player.
- #valid?(attribute, attribute_name) ⇒ Boolean
Constructor Details
#initialize(name, skill) ⇒ Player
Returns a new instance of Player.
6 7 8 9 |
# File 'lib/football-manager/player.rb', line 6 def initialize(name, skill) @name = name if valid?(name, 'name') @skill = skill.to_i if valid?(skill, 'skill') end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/football-manager/player.rb', line 4 def name @name end |
#skill ⇒ Object
Returns the value of attribute skill.
4 5 6 |
# File 'lib/football-manager/player.rb', line 4 def skill @skill end |
Instance Method Details
#valid?(attribute, attribute_name) ⇒ Boolean
11 12 13 |
# File 'lib/football-manager/player.rb', line 11 def valid?(attribute, attribute_name) attribute.nil? ? fail(FootballManager::PlayerError, "You cannot create a player with no #{attribute_name}") : true end |