class Team

Model for a team

Overview

Singles teams are created as needed to allow a player to be an opponent in a match.

Schema Information

Table name: teams

id               :integer          not null, primary key
name             :string
first_player_id  :integer          not null
second_player_id :integer
created_at       :datetime         not null
updated_at       :datetime         not null
doubles          :boolean          default(FALSE), not null

Public Instance Methods

include_player?(player) click to toggle source

Indicate whether the team includes a particular player

  • Args :

  • Returns : Boolean

# File app/models/team.rb, line 54
def include_player?(player)
  include_players?([player])
end
include_players?(players) click to toggle source

Indicate whether the team includes all players in a list

  • Args :

    • players -> array of players

  • Returns : Boolean

# File app/models/team.rb, line 46
def include_players?(players)
  players == [first_player, second_player] & players.compact
end