Class: SportsManager::ByeMatch
- Defined in:
- lib/sports_manager/bye_match.rb
Overview
Public: a Match where it has only one team. This match is a placeholder used to create the next rounds. The team in this match will automatically play on the next round.
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#depends_on ⇒ Object
readonly
Returns the value of attribute depends_on.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#round ⇒ Object
readonly
Returns the value of attribute round.
-
#team1 ⇒ Object
readonly
Returns the value of attribute team1.
-
#team2 ⇒ Object
readonly
Returns the value of attribute team2.
-
#teams ⇒ Object
readonly
Returns the value of attribute teams.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #dependencies ⇒ Object
- #dependencies? ⇒ Boolean
-
#initialize(category:, id: nil, team1: nil, team2: nil, round: 0, depends_on: []) ⇒ ByeMatch
constructor
rubocop:disable Metrics/ParameterLists, Lint/UnusedMethodArgument.
- #participants ⇒ Object
- #playable? ⇒ Boolean
- #playable_dependencies ⇒ Object
- #previous_matches ⇒ Object
- #previous_matches? ⇒ Boolean
- #teams_names ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(category:, id: nil, team1: nil, team2: nil, round: 0, depends_on: []) ⇒ ByeMatch
rubocop:disable Metrics/ParameterLists, Lint/UnusedMethodArgument
10 11 12 13 14 15 16 17 18 |
# File 'lib/sports_manager/bye_match.rb', line 10 def initialize(category:, id: nil, team1: nil, team2: nil, round: 0, depends_on: []) # rubocop:disable Metrics/ParameterLists, Lint/UnusedMethodArgument @id = id @category = category @team1 = team1 @team2 = team2 @round = round @teams = [team1, team2].compact @depends_on = [] end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
8 9 10 |
# File 'lib/sports_manager/bye_match.rb', line 8 def category @category end |
#depends_on ⇒ Object (readonly)
Returns the value of attribute depends_on.
8 9 10 |
# File 'lib/sports_manager/bye_match.rb', line 8 def depends_on @depends_on end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/sports_manager/bye_match.rb', line 8 def id @id end |
#round ⇒ Object (readonly)
Returns the value of attribute round.
8 9 10 |
# File 'lib/sports_manager/bye_match.rb', line 8 def round @round end |
#team1 ⇒ Object (readonly)
Returns the value of attribute team1.
8 9 10 |
# File 'lib/sports_manager/bye_match.rb', line 8 def team1 @team1 end |
#team2 ⇒ Object (readonly)
Returns the value of attribute team2.
8 9 10 |
# File 'lib/sports_manager/bye_match.rb', line 8 def team2 @team2 end |
#teams ⇒ Object (readonly)
Returns the value of attribute teams.
8 9 10 |
# File 'lib/sports_manager/bye_match.rb', line 8 def teams @teams end |
Instance Method Details
#==(other) ⇒ Object
56 57 58 59 60 |
# File 'lib/sports_manager/bye_match.rb', line 56 def ==(other) return false unless instance_of?(other.class) id == other.id && category == other.category && round == other.round end |
#dependencies ⇒ Object
32 33 34 |
# File 'lib/sports_manager/bye_match.rb', line 32 def dependencies [] end |
#dependencies? ⇒ Boolean
28 29 30 |
# File 'lib/sports_manager/bye_match.rb', line 28 def dependencies? false end |
#participants ⇒ Object
24 25 26 |
# File 'lib/sports_manager/bye_match.rb', line 24 def participants @participants ||= teams.map(&:participants).flatten end |
#playable? ⇒ Boolean
20 21 22 |
# File 'lib/sports_manager/bye_match.rb', line 20 def playable? false end |
#playable_dependencies ⇒ Object
36 37 38 |
# File 'lib/sports_manager/bye_match.rb', line 36 def playable_dependencies [] end |
#previous_matches ⇒ Object
44 45 46 |
# File 'lib/sports_manager/bye_match.rb', line 44 def previous_matches [] end |
#previous_matches? ⇒ Boolean
40 41 42 |
# File 'lib/sports_manager/bye_match.rb', line 40 def previous_matches? false end |
#teams_names ⇒ Object
52 53 54 |
# File 'lib/sports_manager/bye_match.rb', line 52 def teams_names teams.map(&:name).reject(&:empty?) end |
#title ⇒ Object
48 49 50 |
# File 'lib/sports_manager/bye_match.rb', line 48 def title teams_names.join.concat(' | BYE') end |