Module: Olympic::Bracket::SingleElimination::Information
- Extended by:
- Memoist
- Included in:
- Olympic::Bracket::SingleElimination
- Defined in:
- lib/olympic/bracket/single_elimination/information.rb
Overview
General information about the tournament.
Instance Method Summary collapse
-
#byes ⇒ Numeric
The number of byes that are required in the bracket.
-
#first_round_matches ⇒ Numeric
The number of matches in the first round.
-
#matches ⇒ Numeric+
Returns the number of expected matches in the bracket.
-
#rounded_teams ⇒ Numeric
In an elimination tournament, the number of teams has to be rounded to the nearest power of two to calculate the number of byes.
-
#rounds ⇒ Numeric+
Returns the number of expected rounds in the bracket.
Instance Method Details
#byes ⇒ Numeric
The number of byes that are required in the bracket. This should be greater than or equal to zero.
32 33 34 |
# File 'lib/olympic/bracket/single_elimination/information.rb', line 32 def byes rounded_teams - @teams.size end |
#first_round_matches ⇒ Numeric
The number of matches in the first round. This will always be a finite number, so this method will never return an array of numbers.
38 39 40 |
# File 'lib/olympic/bracket/single_elimination/information.rb', line 38 def first_round_matches @teams.size - 2 ** Math.log2(@teams.size).floor end |
#matches ⇒ Numeric+
Returns the number of expected matches in the bracket. If the number of matches is variable, it will return an array of numbers, which contains potential values for the number of matches in the bracket.
14 15 16 |
# File 'lib/olympic/bracket/single_elimination/information.rb', line 14 def matches @teams.size - 1 end |
#rounded_teams ⇒ Numeric
In an elimination tournament, the number of teams has to be rounded to the nearest power of two to calculate the number of byes. If this is not necessary, it will return the number of teams.
26 27 28 |
# File 'lib/olympic/bracket/single_elimination/information.rb', line 26 def rounded_teams 2 ** rounds end |
#rounds ⇒ Numeric+
Returns the number of expected rounds in the bracket. If the number of rounds is variable, it will return an array of numbers, which contains potential values for the number of rounds in the bracket.
20 21 22 |
# File 'lib/olympic/bracket/single_elimination/information.rb', line 20 def rounds Math.log2(@teams.size).ceil end |