Sha256: e2758877689317424f88fbacc2d1947fb9e85665c738ba65a47717a3c82d49c5
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module SportsManager class Tournament # Public: The tournament's configurations class Setting attr_reader :match_time, :break_time, :courts, :tournament_days, :single_day_matches def initialize(match_time:, break_time:, courts:, tournament_days:, single_day_matches:) @match_time = match_time @break_time = break_time @courts = courts @tournament_days = tournament_days @single_day_matches = single_day_matches end def ==(other) return false unless instance_of?(other.class) match_time == other.match_time && break_time == other.break_time && courts == other.courts && tournament_days == other.tournament_days && single_day_matches == other.single_day_matches end def timeslots @timeslots ||= tournament_days.flat_map(&method(:build_day_slots)) end def court_list @court_list ||= courts.times.to_a end private def build_day_slots(tournament_day) tournament_day .timeslots(interval: break_time) .yield_self { |slots| court_list.product(slots) } .map { |(court, slot)| Timeslot.new(court: court, date: tournament_day, slot: slot) } 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/setting.rb |
sports-manager-0.0.2 | lib/sports_manager/tournament/setting.rb |
sports-manager-0.0.1 | lib/sports_manager/tournament/setting.rb |