icu_tournament 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,7 +54,7 @@ See ICU::Player and ICU::Result for more details about players and results.
|
|
54
54
|
|
55
55
|
== Validation
|
56
56
|
|
57
|
-
A tournament can be validated with either the
|
57
|
+
A tournament can be validated with either the <em>validate!</em> or _invalid_ methods.
|
58
58
|
On success, the first returns true while the second returns false.
|
59
59
|
On error, the first throws an exception while the second returns a string
|
60
60
|
describing the error.
|
@@ -67,7 +67,7 @@ Validations checks that:
|
|
67
67
|
* the tournament dates (start, finish, round dates), if there are any, are consistent
|
68
68
|
* the player ranks are consistent with their scores
|
69
69
|
|
70
|
-
Side effects of calling
|
70
|
+
Side effects of calling <em>validate!</em> or _invalid_ include:
|
71
71
|
|
72
72
|
* the number of rounds will be set if not set already
|
73
73
|
* the finish date will be set if not set already and if there are round dates
|
@@ -345,8 +345,8 @@ The return value from _renumber_ is the tournament object itself.
|
|
345
345
|
false
|
346
346
|
end
|
347
347
|
|
348
|
-
# Raise an exception if a tournament is not valid.
|
349
|
-
#
|
348
|
+
# Raise an exception if a tournament is not valid. The _rerank_ option can be set to _true_
|
349
|
+
# to rank the tournament just prior to the test if ranking data is missing or inconsistent.
|
350
350
|
def validate!(options={})
|
351
351
|
begin check_ranks rescue rerank end if options[:rerank]
|
352
352
|
check_players
|
@@ -15,15 +15,15 @@ files with the same name but different endings: <em>.ini</em> for meta data such
|
|
15
15
|
rules, <em>.trn</em> for the player details such as name and rating, and <em>.sco</em> for the results. The first
|
16
16
|
file is text and the other two are in an old binary format known as <em>DBase 3</em>.
|
17
17
|
|
18
|
-
To parse such a set of files, use either the
|
18
|
+
To parse such a set of files, use either the <em>parse_file!</em> or _parse_file_ method supplying the name of any one
|
19
19
|
of the three files or just the stem name without any ending. In case of error, such as any of the files not being
|
20
|
-
found,
|
20
|
+
found, <em>parse_file!</em> will throw an exception while _parse_file_ will return _nil_ and record an error message.
|
21
21
|
As well as a file name or stem name, you should also supply a start date in the options as SwissPerfect does not
|
22
22
|
record this information.
|
23
23
|
|
24
24
|
parser = ICU::Tournament::SwissPerfect.new
|
25
25
|
tournament = parser.parse_file('champs', :start => '2010-07-03') # looks for "champs.ini", "champs.trn" and "champs.sco"
|
26
|
-
puts parser.error
|
26
|
+
puts tournament ? 'ok' : "problem: #{parser.error}"
|
27
27
|
|
28
28
|
Alternatively, if all three files are in a ZIP archive, the parser will extract them if the name of the
|
29
29
|
archive file is supplied to the _parse_file_ method and it ends in ".zip" (case insensitive):
|