Class: SportsManager::Tournament::Setting

Inherits:
Object
  • Object
show all
Defined in:
lib/sports_manager/tournament/setting.rb

Overview

Public: The tournament’s configurations

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(match_time:, break_time:, courts:, tournament_days:, single_day_matches:) ⇒ Setting

Returns a new instance of Setting.



9
10
11
12
13
14
15
# File 'lib/sports_manager/tournament/setting.rb', line 9

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

Instance Attribute Details

#break_timeObject (readonly)

Returns the value of attribute break_time.



7
8
9
# File 'lib/sports_manager/tournament/setting.rb', line 7

def break_time
  @break_time
end

#courtsObject (readonly)

Returns the value of attribute courts.



7
8
9
# File 'lib/sports_manager/tournament/setting.rb', line 7

def courts
  @courts
end

#match_timeObject (readonly)

Returns the value of attribute match_time.



7
8
9
# File 'lib/sports_manager/tournament/setting.rb', line 7

def match_time
  @match_time
end

#single_day_matchesObject (readonly)

Returns the value of attribute single_day_matches.



7
8
9
# File 'lib/sports_manager/tournament/setting.rb', line 7

def single_day_matches
  @single_day_matches
end

#tournament_daysObject (readonly)

Returns the value of attribute tournament_days.



7
8
9
# File 'lib/sports_manager/tournament/setting.rb', line 7

def tournament_days
  @tournament_days
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/sports_manager/tournament/setting.rb', line 17

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

#court_listObject



31
32
33
# File 'lib/sports_manager/tournament/setting.rb', line 31

def court_list
  @court_list ||= courts.times.to_a
end

#timeslotsObject



27
28
29
# File 'lib/sports_manager/tournament/setting.rb', line 27

def timeslots
  @timeslots ||= tournament_days.flat_map(&method(:build_day_slots))
end