Module: Olympic::Match
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/olympic/match.rb
Instance Method Summary collapse
-
#completed? ⇒ Boolean
If this match has a winner defined; or, in other words, is completed.
-
#participants ⇒ Array<Olympic::Team>?
Returns the teams that are a part of the match.
-
#ready? ⇒ Boolean
If this match is ready to commence.
Instance Method Details
#completed? ⇒ Boolean
If this match has a winner defined; or, in other words, is completed.
43 44 45 |
# File 'lib/olympic/match.rb', line 43 def completed? winner? end |
#participants ⇒ Array<Olympic::Team>?
Returns the teams that are a part of the match. If the teams cannot be decided, it will return nil.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/olympic/match.rb', line 51 def participants winners = incoming.includes(:source).map do |income| source = income.source case source when Settings.class_for(:team) source when Settings.class_for(:match) source.winner else raise Olympic::Error, "Unknown source #{source}" end end if winners.any? { |winner| winner == nil } nil else winners end end |
#ready? ⇒ Boolean
If this match is ready to commence. This means that the participants are defined.
35 36 37 |
# File 'lib/olympic/match.rb', line 35 def ready? !!participants end |