Class: Olympic::Bracket::Base

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

SingleElimination

Instance Method Summary collapse

Constructor Details

#initialize(tournament, teams) ⇒ Base

Initialize the bracket.

Parameters:



14
15
16
17
# File 'lib/olympic/bracket/base.rb', line 14

def initialize(tournament, teams)
  @tournament = tournament
  @teams = teams
end

Instance Method Details

#byesNumeric

The number of byes that are required in the bracket. This should be greater than or equal to zero.

Returns:

  • (Numeric)


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

#callvoid

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_matchesNumeric

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.

Returns:

  • (Numeric)


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

#matchesNumeric+

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.

Returns:

  • (Numeric, Array<Numeric>)


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_teamsNumeric

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.

Returns:

  • (Numeric)


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

#roundsNumeric+

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.

Returns:

  • (Numeric, Array<Numeric>)


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