Class: FootballManager::Team

Inherits:
Object
  • Object
show all
Defined in:
lib/football-manager/team.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTeam

Returns a new instance of Team.



5
6
7
# File 'lib/football-manager/team.rb', line 5

def initialize
  @players = []
end

Instance Attribute Details

#playersObject (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

Returns:

  • (Boolean)


13
14
15
# File 'lib/football-manager/team.rb', line 13

def empty?
  @players.empty?
end

#players_ordered_by_nameObject



25
26
27
# File 'lib/football-manager/team.rb', line 25

def players_ordered_by_name
  @players.sort_by { |player| player.name }
end

#pointsObject



21
22
23
# File 'lib/football-manager/team.rb', line 21

def points
  @players.inject(0) { |total_skill, player| total_skill + player.skill}
end

#sizeObject



17
18
19
# File 'lib/football-manager/team.rb', line 17

def size
  @players.size
end