class SciolyFF::Interpreter::Team
Models an instance of a Science Olympiad team at a specific tournament
Attributes
penalties[R]
placings[R]
subdivision_team[R]
Public Instance Methods
city()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 48 def city @rep[:city] end
disqualified?()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 40 def disqualified? @rep[:disqualified] || false end
earned_bid?()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 68 def earned_bid? school_rank = @tournament.teams_eligible_for_bids.find_index(self) !school_rank.nil? && school_rank < @tournament.bids end
exhibition?()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 36 def exhibition? @rep[:exhibition] || false end
link_to_other_models(interpreter)
click to toggle source
Calls superclass method
SciolyFF::Interpreter::Model#link_to_other_models
# File lib/sciolyff/interpreter/team.rb, line 8 def link_to_other_models(interpreter) super @placings = interpreter.placings .select { |p| p.team == self } @penalties = interpreter.penalties.select { |p| p.team == self } @placings_by_event = @placings.group_by(&:event).transform_values!(&:first) link_to_team_in_subdivision_interpreter(interpreter) end
medal_counts()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 87 def medal_counts (1..@tournament.events.first.maximum_points).map do |medal_points| placings.select(&:considered_for_team_points?) .count { |p| p.points == medal_points } end end
number()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 44 def number @rep[:number] end
placing_for(event)
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 56 def placing_for(event) @placings_by_event[event] end
points()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 64 def points @points ||= placings.sum(&:points) + penalties.sum(&:points) end
rank()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 60 def rank @tournament.teams.find_index(self) + 1 end
school()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 20 def school @rep[:school] end
school_abbreviation()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 24 def school_abbreviation @rep[:'school abbreviation'] end
state()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 52 def state @rep[:state] end
subdivision()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 32 def subdivision @rep[:subdivision] end
suffix()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 28 def suffix @rep[:suffix] end
trial_event_medal_counts()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 94 def trial_event_medal_counts (1..@tournament.events.last.maximum_points).map do |medal_points| placings.select { |p| p.event.trial? } .count { |p| p.isolated_points == medal_points } end end
trial_event_points()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 83 def trial_event_points placings.select { |p| p.event.trial? }.sum(&:isolated_points) end
worst_placings_to_be_dropped()
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 73 def worst_placings_to_be_dropped return [] if @tournament.worst_placings_dropped.zero? placings .select(&:initially_considered_for_team_points?) .sort_by(&:isolated_points) .reverse .take(@tournament.worst_placings_dropped) end
Private Instance Methods
link_to_team_in_subdivision_interpreter(interpreter)
click to toggle source
# File lib/sciolyff/interpreter/team.rb, line 103 def link_to_team_in_subdivision_interpreter(interpreter) return @subdivision_team = nil unless (sub = subdivision) @subdivision_team = interpreter.subdivisions[sub].teams.find do |t| t.number == number end end