Class: SportsManager::ConstraintBuilder
- Defined in:
- lib/sports_manager/constraint_builder.rb
Constant Summary collapse
- DEFAULT_CONSTRAINTS =
[ Constraints::AllDifferentConstraint, Constraints::NoOverlappingConstraint, Constraints::MatchConstraint, Constraints::MultiCategoryConstraint, Constraints::NextRoundConstraint ].freeze
Instance Attribute Summary collapse
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
-
#tournament ⇒ Object
readonly
Returns the value of attribute tournament.
Class Method Summary collapse
Instance Method Summary collapse
- #build(csp) ⇒ Object
-
#initialize(tournament:, constraints: nil) ⇒ ConstraintBuilder
constructor
A new instance of ConstraintBuilder.
Constructor Details
#initialize(tournament:, constraints: nil) ⇒ ConstraintBuilder
19 20 21 22 |
# File 'lib/sports_manager/constraint_builder.rb', line 19 def initialize(tournament:, constraints: nil) @tournament = tournament @constraints = constraints || DEFAULT_CONSTRAINTS end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
5 6 7 |
# File 'lib/sports_manager/constraint_builder.rb', line 5 def constraints @constraints end |
#tournament ⇒ Object (readonly)
Returns the value of attribute tournament.
5 6 7 |
# File 'lib/sports_manager/constraint_builder.rb', line 5 def tournament @tournament end |
Class Method Details
.build(tournament:, csp:, constraints: nil) ⇒ Object
15 16 17 |
# File 'lib/sports_manager/constraint_builder.rb', line 15 def self.build(tournament:, csp:, constraints: nil) new(tournament: tournament, constraints: constraints).build(csp) end |
Instance Method Details
#build(csp) ⇒ Object
24 25 26 27 28 |
# File 'lib/sports_manager/constraint_builder.rb', line 24 def build(csp) constraints.map do |constraint| constraint.for_tournament(tournament: tournament, csp: csp) end end |