Class: SportsManager::ByeMatch

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#categoryObject (readonly)

Returns the value of attribute category.



8
9
10
# File 'lib/sports_manager/bye_match.rb', line 8

def category
  @category
end

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

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/sports_manager/bye_match.rb', line 8

def id
  @id
end

#roundObject (readonly)

Returns the value of attribute round.



8
9
10
# File 'lib/sports_manager/bye_match.rb', line 8

def round
  @round
end

#team1Object (readonly)

Returns the value of attribute team1.



8
9
10
# File 'lib/sports_manager/bye_match.rb', line 8

def team1
  @team1
end

#team2Object (readonly)

Returns the value of attribute team2.



8
9
10
# File 'lib/sports_manager/bye_match.rb', line 8

def team2
  @team2
end

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

#dependenciesObject



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

#participantsObject



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_dependenciesObject



36
37
38
# File 'lib/sports_manager/bye_match.rb', line 36

def playable_dependencies
  []
end

#previous_matchesObject



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_namesObject



52
53
54
# File 'lib/sports_manager/bye_match.rb', line 52

def teams_names
  teams.map(&:name).reject(&:empty?)
end

#titleObject



48
49
50
# File 'lib/sports_manager/bye_match.rb', line 48

def title
  teams_names.join.concat(' | BYE')
end