Class: Basketball::Season::Matchup
- Inherits:
-
Object
- Object
- Basketball::Season::Matchup
- Defined in:
- lib/basketball/season/matchup.rb
Overview
A Matchup is a late materialization of a game. While a game is a skeleton for a future matchup, it does not materialize until game time (rosters could change right up until game time).
Defined Under Namespace
Classes: PlayersOnBothTeamsError
Instance Attribute Summary collapse
-
#away_players ⇒ Object
readonly
Returns the value of attribute away_players.
-
#game ⇒ Object
readonly
Returns the value of attribute game.
-
#home_players ⇒ Object
readonly
Returns the value of attribute home_players.
Instance Method Summary collapse
-
#initialize(game:, home_players: [], away_players: []) ⇒ Matchup
constructor
A new instance of Matchup.
Constructor Details
#initialize(game:, home_players: [], away_players: []) ⇒ Matchup
Returns a new instance of Matchup.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/basketball/season/matchup.rb', line 12 def initialize(game:, home_players: [], away_players: []) raise ArgumentError, 'game is required' unless game @game = game @home_players = home_players.uniq @away_players = away_players.uniq if home_players.intersect?(away_players) raise PlayersOnBothTeamsError, 'players cannot be on both home and away team' end freeze end |
Instance Attribute Details
#away_players ⇒ Object (readonly)
Returns the value of attribute away_players.
10 11 12 |
# File 'lib/basketball/season/matchup.rb', line 10 def away_players @away_players end |
#game ⇒ Object (readonly)
Returns the value of attribute game.
10 11 12 |
# File 'lib/basketball/season/matchup.rb', line 10 def game @game end |
#home_players ⇒ Object (readonly)
Returns the value of attribute home_players.
10 11 12 |
# File 'lib/basketball/season/matchup.rb', line 10 def home_players @home_players end |