Module: Tournament::Swiss

Extended by:
Swiss
Included in:
Swiss
Defined in:
lib/tournament/swiss.rb,
lib/tournament/swiss/dutch.rb

Overview

Implements the swiss tournament system

Defined Under Namespace

Modules: Dutch

Instance Method Summary collapse

Instance Method Details

#generate(driver, options = {}) ⇒ nil

Generate matches with the given driver.

Parameters:

  • driver (Driver)
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • pairer (Pairer)

    the pairing system to use, defaults to Dutch

  • pair_options (Hash)

    options for the chosen pairing system, see Dutch for more details

Returns:

  • (nil)


17
18
19
20
21
22
23
24
# File 'lib/tournament/swiss.rb', line 17

def generate(driver, options = {})
  pairer = options[:pairer] || Dutch
  pairer_options = options[:pair_options] || {}

  pairings = pairer.pair(driver, pairer_options)

  driver.create_matches(pairings)
end

#minimum_rounds(driver) ⇒ Integer

The minimum number of rounds to determine a number of winners.

Parameters:

Returns:

  • (Integer)


30
31
32
# File 'lib/tournament/swiss.rb', line 30

def minimum_rounds(driver)
  Algorithm::Swiss.minimum_rounds(driver.seeded_teams.length)
end