Class: SportsManager::TournamentSolution
- Defined in:
- lib/sports_manager/tournament_solution.rb,
lib/sports_manager/tournament_solution/fixture.rb,
lib/sports_manager/tournament_solution/solution.rb,
lib/sports_manager/tournament_solution/serializer.rb,
lib/sports_manager/tournament_solution/bye_fixture.rb
Overview
Public: A tournament with its possible solutions containing the fixtures for each solution
Note: Fixture is a schedule for the participating teams.
Defined Under Namespace
Classes: ByeFixture, Fixture, Serializer, Solution
Instance Attribute Summary collapse
-
#tournament ⇒ Object
readonly
Returns the value of attribute tournament.
-
#tournament_solutions ⇒ Object
readonly
Returns the value of attribute tournament_solutions.
Instance Method Summary collapse
- #as_json(options = nil) ⇒ Object
-
#initialize(tournament:, solutions:) ⇒ TournamentSolution
constructor
A new instance of TournamentSolution.
- #solutions ⇒ Object
- #solved? ⇒ Boolean
- #total_solutions ⇒ Object
Constructor Details
#initialize(tournament:, solutions:) ⇒ TournamentSolution
Returns a new instance of TournamentSolution.
11 12 13 14 |
# File 'lib/sports_manager/tournament_solution.rb', line 11 def initialize(tournament:, solutions:) @tournament = tournament @tournament_solutions = solutions end |
Instance Attribute Details
#tournament ⇒ Object (readonly)
Returns the value of attribute tournament.
9 10 11 |
# File 'lib/sports_manager/tournament_solution.rb', line 9 def tournament @tournament end |
#tournament_solutions ⇒ Object (readonly)
Returns the value of attribute tournament_solutions.
9 10 11 |
# File 'lib/sports_manager/tournament_solution.rb', line 9 def tournament_solutions @tournament_solutions end |
Instance Method Details
#as_json(options = nil) ⇒ Object
30 31 32 |
# File 'lib/sports_manager/tournament_solution.rb', line 30 def as_json( = nil) Serializer.new(self).as_json() end |
#solutions ⇒ Object
16 17 18 19 20 |
# File 'lib/sports_manager/tournament_solution.rb', line 16 def solutions @solutions ||= tournament_solutions .map { |fixtures| Fixture.build_fixtures(fixtures) } .map { |fixtures| Solution.new(fixtures) } end |
#solved? ⇒ Boolean
22 23 24 |
# File 'lib/sports_manager/tournament_solution.rb', line 22 def solved? solutions && !solutions.empty? end |
#total_solutions ⇒ Object
26 27 28 |
# File 'lib/sports_manager/tournament_solution.rb', line 26 def total_solutions solutions.size end |