Class: Olympic::Bracket::Base
- Inherits:
-
Object
- Object
- Olympic::Bracket::Base
- Defined in:
- lib/olympic/bracket/base.rb
Overview
A basic bracket. This defines the basic API that all brackets should have. In order for a bracket to be compatible with Olympic, only these things need to be implemented.
Direct Known Subclasses
Instance Method Summary collapse
-
#byes ⇒ Numeric
The number of byes that are required in the bracket.
-
#call ⇒ void
Initializes the tournament to handle the bracket.
-
#first_round_matches ⇒ Numeric
The number of matches in the first round.
-
#initialize(tournament, teams) ⇒ Base
constructor
Initialize the bracket.
-
#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.
Constructor Details
#initialize(tournament, teams) ⇒ Base
Initialize the bracket.
14 15 16 17 |
# File 'lib/olympic/bracket/base.rb', line 14 def initialize(tournament, teams) @tournament = tournament @teams = teams end |
Instance Method Details
#byes ⇒ Numeric
The number of byes that are required in the bracket. This should be greater than or equal to zero.
62 63 64 65 66 67 |
# File 'lib/olympic/bracket/base.rb', line 62 %(call matches rounds rounded_teams byes first_round_matches).map(&:to_sym).each do |name| define_method(name) do _not_implemented_error(name) end end |
#call ⇒ void
This method returns an undefined value.
Initializes the tournament to handle the bracket. Sets up all matches and sources in accordance to the bracket itself.
62 63 64 65 66 67 |
# File 'lib/olympic/bracket/base.rb', line 62 %(call matches rounds rounded_teams byes first_round_matches).map(&:to_sym).each do |name| define_method(name) do _not_implemented_error(name) end 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.
62 63 64 65 66 67 |
# File 'lib/olympic/bracket/base.rb', line 62 %(call matches rounds rounded_teams byes first_round_matches).map(&:to_sym).each do |name| define_method(name) do _not_implemented_error(name) end 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.
62 63 64 65 66 67 |
# File 'lib/olympic/bracket/base.rb', line 62 %(call matches rounds rounded_teams byes first_round_matches).map(&:to_sym).each do |name| define_method(name) do _not_implemented_error(name) end 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.
62 63 64 65 66 67 |
# File 'lib/olympic/bracket/base.rb', line 62 %(call matches rounds rounded_teams byes first_round_matches).map(&:to_sym).each do |name| define_method(name) do _not_implemented_error(name) end 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.
62 63 64 65 66 67 |
# File 'lib/olympic/bracket/base.rb', line 62 %(call matches rounds rounded_teams byes first_round_matches).map(&:to_sym).each do |name| define_method(name) do _not_implemented_error(name) end end |