Sha256: a2a795536528dc7d613752ad7b5ad8ed4326ec347c5c359e9ef28ae5f0e0673a

Contents?: true

Size: 978 Bytes

Versions: 3

Compression:

Stored size: 978 Bytes

Contents

# frozen_string_literal: true

module SportsManager
  class TournamentSolution
    # Public: A schedule for the participating teams.
    class Fixture
      extend Forwardable

      attr_reader :match, :timeslot, :category

      def_delegator :match, :id, :match_id
      def_delegators :match, :title, :depends_on, :playable?,
                     :dependencies, :dependencies?, :round
      def_delegators :timeslot, :court, :slot

      def self.build_fixtures(fixtures)
        fixtures.map { |(match, timeslot)| new(match: match, timeslot: timeslot) }
      end

      def initialize(match:, timeslot:)
        @match = match
        @timeslot = timeslot
        @category = match.category
      end

      def depends_on?(fixture)
        depends_on
          .map(&:id)
          .include?(fixture.match_id)
      end

      def bye_dependencies
        depends_on
          .reject(&:playable?)
          .map { |bye| ByeFixture.new(bye) }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sports-manager-0.0.3 lib/sports_manager/tournament_solution/fixture.rb
sports-manager-0.0.2 lib/sports_manager/tournament_solution/fixture.rb
sports-manager-0.0.1 lib/sports_manager/tournament_solution/fixture.rb