Module: TournamentSystem::Algorithm::PagePlayoff

Extended by:
PagePlayoff
Included in:
PagePlayoff
Defined in:
lib/tournament_system/algorithm/page_playoff.rb

Overview

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

Constant Summary collapse

TOTAL_ROUNDS =

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

3

Instance Method Summary collapse

Instance Method Details

#guess_round(matches_count) ⇒ Integer

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

Parameters:

  • matches_count (Integer)

    the number of existing matches

Returns:

  • (Integer)

Raises:

  • (ArgumentError)

    when the number of matches doesn’t add up



25
26
27
28
29
30
31
# 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