Class: Basketball::Season::Scheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/basketball/season/scheduler.rb

Overview

This is the service class responsible for actually picking out free dates and pairing up teams to play each other. This is a reasonable naive first pass at some underlying match-making algorithms but could definitely use some help with the complexity/runtime/etc.

Defined Under Namespace

Classes: BadConferencesSizeError, BadDivisionsSizeError, BadTeamsSizeError

Instance Method Summary collapse

Instance Method Details

#schedule(league:, year: Time.now.year) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/basketball/season/scheduler.rb', line 25

def schedule(league:, year: Time.now.year)
  assert_properly_sized_league(league)

  Calendar.new(**make_dates(year)).tap do |calendar|
    schedule_exhibition!(calendar:, league:)
    schedule_season!(calendar:, league:)
  end
end