Class: SciolyFF::Interpreter::Placing
- Inherits:
-
Model
- Object
- Model
- SciolyFF::Interpreter::Placing
show all
- Defined in:
- lib/sciolyff/interpreter/placing.rb
Overview
Models the result of a team participating (or not) in an event
Defined Under Namespace
Classes: Raw
Instance Attribute Summary collapse
Attributes inherited from Model
#tournament
Instance Method Summary
collapse
Methods inherited from Model
#initialize, #inspect
Instance Attribute Details
#event ⇒ Object
Returns the value of attribute event.
18
19
20
|
# File 'lib/sciolyff/interpreter/placing.rb', line 18
def event
@event
end
|
#subdivision_placing ⇒ Object
Returns the value of attribute subdivision_placing.
18
19
20
|
# File 'lib/sciolyff/interpreter/placing.rb', line 18
def subdivision_placing
@subdivision_placing
end
|
#team ⇒ Object
Returns the value of attribute team.
18
19
20
|
# File 'lib/sciolyff/interpreter/placing.rb', line 18
def team
@team
end
|
Instance Method Details
#considered_for_team_points? ⇒ Boolean
81
82
83
84
|
# 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? ⇒ Boolean
52
53
54
|
# File 'lib/sciolyff/interpreter/placing.rb', line 52
def did_not_participate?
!participated?
end
|
#disqualified? ⇒ Boolean
24
25
26
|
# File 'lib/sciolyff/interpreter/placing.rb', line 24
def disqualified?
@rep[:disqualified] || false
end
|
#dropped_as_part_of_worst_placings? ⇒ Boolean
60
61
62
|
# 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? ⇒ Boolean
28
29
30
|
# File 'lib/sciolyff/interpreter/placing.rb', line 28
def exempt?
@rep[:exempt] || false
end
|
#initially_considered_for_team_points? ⇒ Boolean
86
87
88
|
# File 'lib/sciolyff/interpreter/placing.rb', line 86
def initially_considered_for_team_points?
!(event.trial? || event.trialed? || exempt?)
end
|
#isolated_points ⇒ Object
70
71
72
73
74
75
76
77
78
79
|
# 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) ⇒ Object
10
11
12
13
14
15
16
|
# 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? ⇒ Boolean
20
21
22
|
# File 'lib/sciolyff/interpreter/placing.rb', line 20
def participated?
@rep[:participated] || @rep[:participated].nil?
end
|
#participation_only? ⇒ Boolean
56
57
58
|
# File 'lib/sciolyff/interpreter/placing.rb', line 56
def participation_only?
participated? && !place && !disqualified? && !unknown?
end
|
#place ⇒ Object
40
41
42
|
# File 'lib/sciolyff/interpreter/placing.rb', line 40
def place
raw? ? @place ||= event.raws.find_index(raw) + 1 : @rep[:place]
end
|
#points ⇒ Object
64
65
66
67
68
|
# 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? ⇒ Boolean
90
91
92
|
# 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? ⇒ Boolean
94
95
96
97
98
99
100
101
|
# 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 ⇒ Object
44
45
46
|
# File 'lib/sciolyff/interpreter/placing.rb', line 44
def raw
@raw ||= Raw.new(@rep[:raw], event.low_score_wins?) if raw?
end
|
#raw? ⇒ Boolean
48
49
50
|
# File 'lib/sciolyff/interpreter/placing.rb', line 48
def raw?
@rep.key? :raw
end
|
#tie? ⇒ Boolean
36
37
38
|
# File 'lib/sciolyff/interpreter/placing.rb', line 36
def tie?
raw? ? @tie ||= event.raws.count(raw) > 1 : @rep[:tie] == true
end
|
#unknown? ⇒ Boolean
32
33
34
|
# File 'lib/sciolyff/interpreter/placing.rb', line 32
def unknown?
@rep[:unknown] || false
end
|