module TournamentSystem::Algorithm::PagePlayoff

This module provides algorithms for dealing with the page playoff system.

Constants

MATCH_ROUND_MAP

Mapping from number of matches to round number

TOTAL_ROUNDS

The total number of rounds needed for all page playoff tournaments.

Public Instance Methods

guess_round(matches_count) click to toggle source

Guess the next round (starting at 0) for page playoff.

@param matches_count [Integer] the number of existing matches @return [Integer] @raise [ArgumentError] when the number of matches doesn't add up

# File lib/tournament_system/algorithm/page_playoff.rb, line 25
def guess_round(matches_count)
  round = MATCH_ROUND_MAP[matches_count]

  raise ArgumentError, 'Invalid number of matches' unless round

  round
end