module SciolyFF::Interpreter::Tiebreaks
Tie-breaking logic for teams, to be used in the Interpreter
class
Private Instance Methods
break_second_tie(team_a, team_b)
click to toggle source
# File lib/sciolyff/interpreter/tiebreaks.rb, line 22 def break_second_tie(team_a, team_b) cmp = team_a.trial_event_points <=> team_b.trial_event_points cmp.zero? ? break_third_tie(team_a, team_b) : cmp end
break_third_tie(team_a, team_b)
click to toggle source
# File lib/sciolyff/interpreter/tiebreaks.rb, line 27 def break_third_tie(team_a, team_b) team_a.trial_event_medal_counts .zip(team_b.trial_event_medal_counts) .map { |counts| counts.last - counts.first } .find(proc { team_a.number <=> team_b.number }, &:nonzero?) end
break_tie(team_a, team_b)
click to toggle source
# File lib/sciolyff/interpreter/tiebreaks.rb, line 15 def break_tie(team_a, team_b) team_a.medal_counts .zip(team_b.medal_counts) .map { |counts| counts.last - counts.first } .find(proc { break_second_tie(team_a, team_b) }, &:nonzero?) end
sort_teams_by_points(teams)
click to toggle source
# File lib/sciolyff/interpreter/tiebreaks.rb, line 8 def sort_teams_by_points(teams) teams.sort do |team_a, team_b| cmp = team_a.points <=> team_b.points cmp.zero? ? break_tie(team_a, team_b) : cmp end end