Class: FootballManager::Team
- Inherits:
-
Object
- Object
- FootballManager::Team
- Defined in:
- lib/football-manager/team.rb
Instance Attribute Summary collapse
-
#players ⇒ Object
readonly
Returns the value of attribute players.
Instance Method Summary collapse
- #<<(player) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Team
constructor
A new instance of Team.
- #players_ordered_by_name ⇒ Object
- #points ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize ⇒ Team
Returns a new instance of Team.
5 6 7 |
# File 'lib/football-manager/team.rb', line 5 def initialize @players = [] end |
Instance Attribute Details
#players ⇒ Object (readonly)
Returns the value of attribute players.
3 4 5 |
# File 'lib/football-manager/team.rb', line 3 def players @players end |
Instance Method Details
#<<(player) ⇒ Object
9 10 11 |
# File 'lib/football-manager/team.rb', line 9 def <<(player) @players << player end |
#empty? ⇒ Boolean
13 14 15 |
# File 'lib/football-manager/team.rb', line 13 def empty? @players.empty? end |
#players_ordered_by_name ⇒ Object
25 26 27 |
# File 'lib/football-manager/team.rb', line 25 def players_ordered_by_name @players.sort_by { |player| player.name } end |
#points ⇒ Object
21 22 23 |
# File 'lib/football-manager/team.rb', line 21 def points @players.inject(0) { |total_skill, player| total_skill + player.skill} end |
#size ⇒ Object
17 18 19 |
# File 'lib/football-manager/team.rb', line 17 def size @players.size end |