module Olympic::Match

Public Instance Methods

completed?() click to toggle source

If this match has a winner defined; or, in other words, is completed.

@return [Boolean]

# File lib/olympic/match.rb, line 43
def completed?
  winner?
end
participants() click to toggle source

Returns the teams that are a part of the match. If the teams cannot be decided, it will return nil.

@return [Array<Olympic::Team>, nil]

# 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?() click to toggle source

If this match is ready to commence. This means that the participants are defined.

@return [Boolean]

# File lib/olympic/match.rb, line 35
def ready?
  !!participants
end