class SciolyFF::Interpreter::Placing
Models the result of a team participating (or not) in an event
Attributes
event[R]
subdivision_placing[R]
team[R]
Public Instance Methods
considered_for_team_points?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 81 def considered_for_team_points? initially_considered_for_team_points? && !dropped_as_part_of_worst_placings? end
did_not_participate?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 52 def did_not_participate? !participated? end
disqualified?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 24 def disqualified? @rep[:disqualified] || false end
dropped_as_part_of_worst_placings?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 60 def dropped_as_part_of_worst_placings? team.worst_placings_to_be_dropped.include?(self) end
exempt?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 28 def exempt? @rep[:exempt] || false end
initially_considered_for_team_points?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 86 def initially_considered_for_team_points? !(event.trial? || event.trialed? || exempt?) end
isolated_points()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 70 def isolated_points max_place = event.maximum_place n = max_place + tournament.n_offset if disqualified? then n + 2 elsif did_not_participate? then n + 1 elsif participation_only? || unknown? then n else [calculate_points, max_place].min end end
link_to_other_models(interpreter)
click to toggle source
Calls superclass method
SciolyFF::Interpreter::Model#link_to_other_models
# File lib/sciolyff/interpreter/placing.rb, line 10 def link_to_other_models(interpreter) super @event = interpreter.events.find { |e| e.name == @rep[:event] } @team = interpreter.teams .find { |t| t.number == @rep[:team] } link_to_placing_in_subdivision_interpreter(interpreter) end
participated?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 20 def participated? @rep[:participated] || @rep[:participated].nil? end
participation_only?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 56 def participation_only? participated? && !place && !disqualified? && !unknown? end
place()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 40 def place raw? ? @place ||= event.raws.find_index(raw) + 1 : @rep[:place] end
points()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 64 def points @points ||= if !considered_for_team_points? then 0 else isolated_points end end
points_affected_by_exhibition?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 90 def points_affected_by_exhibition? considered_for_team_points? && place && !exhibition_placings_behind.zero? end
points_limited_by_maximum_place?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 94 def points_limited_by_maximum_place? tournament.custom_maximum_place? && (unknown? || (place && (calculate_points > event.maximum_place || calculate_points == event.maximum_place && tie? ))) end
raw()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 44 def raw @raw ||= Raw.new(@rep[:raw], event.low_score_wins?) if raw? end
raw?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 48 def raw? @rep.key? :raw end
tie?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 36 def tie? raw? ? @tie ||= event.raws.count(raw) > 1 : @rep[:tie] == true end
unknown?()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 32 def unknown? @rep[:unknown] || false end
Private Instance Methods
calculate_points()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 105 def calculate_points return place if event.trial? place - exhibition_placings_behind end
exhibition_placings_behind()
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 111 def exhibition_placings_behind @exhibition_placings_behind ||= event.placings.count do |p| (p.exempt? || p.team.exhibition?) && p.place && p.place < place end end
link_to_placing_in_subdivision_interpreter(interpreter)
click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 119 def link_to_placing_in_subdivision_interpreter(interpreter) return @subdivision_placing = nil unless (sub = team.subdivision) @subdivision_placing = interpreter.subdivisions[sub].placings.find do |p| p.event.name == event.name && p.team.number == team.number end end