sciolyff 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sciolyff +1 -1
- data/lib/sciolyff.rb +20 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5ade4d7bbd00e33e30bfeafffb0b30532e8210280ca6eae2b7720010fff532f
|
4
|
+
data.tar.gz: 6955635e1bb01bb523c21633e4610583b4cabfc0349c9d1e9475ad9b5fae7307
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b308389be5811e1fa13c93d08111d639f3c50dc64c1aed146e103aa048a02512c69558220b6e4e5f68bf10ef18c02a5995cde3715ade6932228cf24a05258c4a
|
7
|
+
data.tar.gz: f38152c0da8db0f4bcd7e0bd19fd473e11a92b6ff6cc09a4a6f21cfbfca1b7ee141e66fc568e9c6c517f0446702cad459eddbfd40cb0e0edc2f9165a3f28a4d9
|
data/bin/sciolyff
CHANGED
data/lib/sciolyff.rb
CHANGED
@@ -54,6 +54,9 @@ module SciolyFF
|
|
54
54
|
|
55
55
|
def initialize(rep)
|
56
56
|
@rep = rep
|
57
|
+
@exhibition_teams_count = rep[:Teams].count { |t| t[:exhibition] }
|
58
|
+
@team_points_cache = {}
|
59
|
+
|
57
60
|
@tournament = rep[:Tournament]
|
58
61
|
@events_by_name = index_array(rep[:Events], [:name])
|
59
62
|
@teams_by_number = index_array(rep[:Teams], [:number])
|
@@ -80,12 +83,9 @@ module SciolyFF
|
|
80
83
|
end
|
81
84
|
|
82
85
|
def team_points(team_number)
|
83
|
-
@
|
84
|
-
|
85
|
-
|
86
|
-
.reject { |p| @events_by_name[p[:event]][:trialed] }
|
87
|
-
.sum { |p| event_points(team_number, p[:event]) } \
|
88
|
-
+ team_points_from_penalties(team_number)
|
86
|
+
return @team_points_cache[team_number] if @team_points_cache[team_number]
|
87
|
+
|
88
|
+
@team_points_cache[team_number] = calculate_team_points(team_number)
|
89
89
|
end
|
90
90
|
|
91
91
|
def team_points_from_penalties(team_number)
|
@@ -134,7 +134,7 @@ module SciolyFF
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def calculate_event_points(placing)
|
137
|
-
return placing[:place] if
|
137
|
+
return placing[:place] if simple_placing?(placing)
|
138
138
|
|
139
139
|
# Points is place minus number of exhibition teams with a better place
|
140
140
|
placing[:place] -
|
@@ -144,6 +144,19 @@ module SciolyFF
|
|
144
144
|
.count { |p| p[:place] < placing[:place] }
|
145
145
|
end
|
146
146
|
|
147
|
+
def calculate_team_points(team_number)
|
148
|
+
@placings_by_team[team_number]
|
149
|
+
.values
|
150
|
+
.reject { |p| @events_by_name[p[:event]][:trial] }
|
151
|
+
.reject { |p| @events_by_name[p[:event]][:trialed] }
|
152
|
+
.sum { |p| event_points(team_number, p[:event]) } \
|
153
|
+
+ team_points_from_penalties(team_number)
|
154
|
+
end
|
155
|
+
|
156
|
+
def simple_placing?(placing)
|
157
|
+
@exhibition_teams_count.zero? || @events_by_name[placing[:event]][:trial]
|
158
|
+
end
|
159
|
+
|
147
160
|
def break_tie(team_number_a, team_number_b)
|
148
161
|
medal_counts(team_number_a)
|
149
162
|
.zip(medal_counts(team_number_b))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sciolyff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Em Zhan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
|
-
rubygems_version: 3.0.
|
91
|
+
rubygems_version: 3.0.4
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: A file format for Science Olympiad tournament results.
|