Class: SciolyFF::Interpreter::Tournament
- Inherits:
-
Model
- Object
- Model
- SciolyFF::Interpreter::Tournament
show all
- Includes:
- Bids
- Defined in:
- lib/sciolyff/interpreter/tournament.rb
Overview
Models a Science Olympiad tournament
Instance Attribute Summary collapse
Attributes inherited from Model
#tournament
Instance Method Summary
collapse
Methods included from Bids
#teams_eligible_for_bids, #top_teams_per_school
Methods inherited from Model
#inspect
Constructor Details
Returns a new instance of Tournament.
9
10
11
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 9
def initialize(rep)
@rep = rep[:Tournament]
end
|
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
21
22
23
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 21
def events
@events
end
|
#penalties ⇒ Object
Returns the value of attribute penalties.
21
22
23
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 21
def penalties
@penalties
end
|
#placings ⇒ Object
Returns the value of attribute placings.
21
22
23
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 21
def placings
@placings
end
|
#subdivisions ⇒ Object
Returns the value of attribute subdivisions.
21
22
23
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 21
def subdivisions
@subdivisions
end
|
#teams ⇒ Object
Returns the value of attribute teams.
21
22
23
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 21
def teams
@teams
end
|
Instance Method Details
#bids ⇒ Object
56
57
58
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 56
def bids
@rep[:bids] || 0
end
|
#bids_per_school ⇒ Object
60
61
62
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 60
def bids_per_school
@rep[:'bids per school'] || 1
end
|
#custom_maximum_place? ⇒ Boolean
80
81
82
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 80
def custom_maximum_place?
maximum_place != nonexhibition_teams_count
end
|
#date ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 40
def date
@date ||= if @rep[:date].instance_of?(Date)
@rep[:date]
else
Date.parse(@rep[:date])
end
end
|
#exempt_placings ⇒ Object
76
77
78
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 76
def exempt_placings
@rep[:'exempt placings'] || 0
end
|
#exempt_placings? ⇒ Boolean
72
73
74
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 72
def exempt_placings?
exempt_placings.positive?
end
|
#link_to_other_models(interpreter) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 13
def link_to_other_models(interpreter)
@events = interpreter.events
@teams = interpreter.teams
@placings = interpreter.placings
@penalties = interpreter.penalties
@subdivisions = interpreter.subdivisions
end
|
#maximum_place ⇒ Object
84
85
86
87
88
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 84
def maximum_place
return @rep[:'maximum place'] if @rep[:'maximum place']
nonexhibition_teams_count
end
|
#medals ⇒ Object
48
49
50
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 48
def medals
@rep[:medals] || [calc_medals, maximum_place].min
end
|
#n_offset ⇒ Object
98
99
100
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 98
def n_offset
@rep[:'n offset'] || 0
end
|
#nonexhibition_teams_count ⇒ Object
116
117
118
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 116
def nonexhibition_teams_count
@nonexhibition_teams_count ||= @teams.count { |t| !t.exhibition? }
end
|
#per_event_n ⇒ Object
90
91
92
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 90
def per_event_n
@rep[:'per-event n']
end
|
#per_event_n? ⇒ Boolean
94
95
96
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 94
def per_event_n?
@rep.key? :'per-event n'
end
|
#short_name ⇒ Object
36
37
38
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 36
def short_name
@rep[:'short name']
end
|
#subdivisions? ⇒ Boolean
112
113
114
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 112
def subdivisions?
!@subdivisions.empty?
end
|
#ties? ⇒ Boolean
102
103
104
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 102
def ties?
@ties ||= placings.map(&:tie?).any?
end
|
#ties_outside_of_maximum_places? ⇒ Boolean
106
107
108
109
110
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 106
def ties_outside_of_maximum_places?
@ties_outside_of_maximum_places ||= placings.map do |p|
p.tie? && !p.points_limited_by_maximum_place?
end.any?
end
|
#trophies ⇒ Object
52
53
54
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 52
def trophies
@rep[:trophies] || [calc_trophies, nonexhibition_teams_count].min
end
|
#worst_placings_dropped ⇒ Object
68
69
70
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 68
def worst_placings_dropped
@rep[:'worst placings dropped'] || 0
end
|
#worst_placings_dropped? ⇒ Boolean
64
65
66
|
# File 'lib/sciolyff/interpreter/tournament.rb', line 64
def worst_placings_dropped?
worst_placings_dropped.positive?
end
|