Sha256: 9a8ee219cac92332a764386e687ae47327bc8ee1db45b278a4022785a576bdc2

Contents?: true

Size: 455 Bytes

Versions: 9

Compression:

Stored size: 455 Bytes

Contents

module FootballManager
  class Team
    attr_reader :players

    def initialize
      @players = []
    end

    def <<(player)
      @players << player
    end

    def empty?
      @players.empty?
    end

    def size
      @players.size
    end

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

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





Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
football-manager-1.0.1 lib/football-manager/team.rb
football-manager-0.1.8 lib/football-manager/team.rb
football-manager-0.1.7 lib/football-manager/team.rb
football-manager-0.1.6 lib/football-manager/team.rb
football-manager-0.1.5 lib/football-manager/team.rb
football-manager-0.1.4 lib/football-manager/team.rb
football-manager-0.1.2 lib/football-manager/team.rb
football-manager-0.1.1 lib/football-manager/team.rb
football-manager-0.1.0 lib/football-manager/team.rb