class SciolyFF::Interpreter::Event
Models an instance of a Science Olympiad event at a specific tournament
Attributes
placings[R]
raws[R]
Public Instance Methods
high_score_wins?()
click to toggle source
# File lib/sciolyff/interpreter/event.rb, line 30 def high_score_wins? !low_score_wins? end
link_to_other_models(interpreter)
click to toggle source
Calls superclass method
SciolyFF::Interpreter::Model#link_to_other_models
# File lib/sciolyff/interpreter/event.rb, line 8 def link_to_other_models(interpreter) super @placings = interpreter.placings.select { |p| p.event == self } @placings_by_team = @placings.group_by(&:team).transform_values!(&:first) @raws = @placings.select(&:raw?).map(&:raw).sort end
low_score_wins?()
click to toggle source
# File lib/sciolyff/interpreter/event.rb, line 34 def low_score_wins? @rep[:scoring] == 'low' end
maximum_place()
click to toggle source
# File lib/sciolyff/interpreter/event.rb, line 42 def maximum_place @maximum_place ||= if trial? placings.size elsif tournament.per_event_n? [per_event_maximum_place, tournament.maximum_place].min else tournament.maximum_place end end
maximum_points()
click to toggle source
# File lib/sciolyff/interpreter/event.rb, line 53 def maximum_points maximum_place + 2 end
name()
click to toggle source
# File lib/sciolyff/interpreter/event.rb, line 18 def name @rep[:name] end
placing_for(team)
click to toggle source
# File lib/sciolyff/interpreter/event.rb, line 38 def placing_for(team) @placings_by_team[team] end
trial?()
click to toggle source
# File lib/sciolyff/interpreter/event.rb, line 22 def trial? @rep[:trial] || false end
trialed?()
click to toggle source
# File lib/sciolyff/interpreter/event.rb, line 26 def trialed? @rep[:trialed] || false end
Private Instance Methods
competing_teams_count()
click to toggle source
# File lib/sciolyff/interpreter/event.rb, line 65 def competing_teams_count return placings.count(&:participated?) if trial? placings.count do |p| p.participated? && !(p.team.exhibition? || p.exempt?) end end
per_event_maximum_place()
click to toggle source
# File lib/sciolyff/interpreter/event.rb, line 59 def per_event_maximum_place return competing_teams_count if tournament.per_event_n == 'participation' placings.map(&:place).compact.max + 1 end