sanichi-chess_icu 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/tournament_fcsv.rb +18 -17
- data/spec/tournament_fcsv_spec.rb +2 -2
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/tournament_fcsv.rb
CHANGED
@@ -38,43 +38,44 @@ This file can be parsed as follows.
|
|
38
38
|
If the file is correctly specified, the return value from the <em>parse</em> method is an instance of
|
39
39
|
ICU::Tournament (rather than <em>nil</em>, which indicates an error). In this example the file is valid, so:
|
40
40
|
|
41
|
-
tournament.name
|
42
|
-
tournament.start
|
43
|
-
tournament.rounds
|
44
|
-
tournament.website
|
41
|
+
tournament.name # => "Isle of Man Masters, 2007"
|
42
|
+
tournament.start # => "2007-09-22"
|
43
|
+
tournament.rounds # => 9
|
44
|
+
tournament.website # => "http://www.bcmchess.co.uk/monarch2007/"
|
45
45
|
|
46
46
|
The main player (the player whose results are being reported for rating) played 9 rounds
|
47
47
|
but only 8 other players (he had a bye in round 6), so the total number of players is 9.
|
48
48
|
|
49
|
-
tournament.players.size
|
49
|
+
tournament.players.size # => 9
|
50
50
|
|
51
51
|
Each player has a unique number for the tournament. The main player always occurs first in this type of file, so his number is 1.
|
52
52
|
|
53
53
|
player = tournament.player(1)
|
54
|
-
player.name
|
54
|
+
player.name # => "Fox, Anthony"
|
55
55
|
|
56
56
|
This player has 4 points from 9 rounds but only 8 of his results are are rateable (because of the bye).
|
57
57
|
|
58
|
-
player.points
|
59
|
-
player.results.size
|
60
|
-
player.results.find_all{ |r| r.rateable }.size
|
58
|
+
player.points # => 4.0
|
59
|
+
player.results.size # => 9
|
60
|
+
player.results.find_all{ |r| r.rateable }.size # => 8
|
61
61
|
|
62
62
|
The other players all have numbers greater than 1.
|
63
63
|
|
64
64
|
opponents = tournamnet.players.reject { |o| o.num == 1 }
|
65
65
|
|
66
|
-
There are 8 opponents of the main player
|
66
|
+
There are 8 opponents (of the main player) each with exactly one game.
|
67
67
|
|
68
|
-
opponents.size
|
69
|
-
opponents.find_all{ |o| o.results.size == 1}.size # => 8
|
68
|
+
opponents.size # => 8
|
69
|
+
opponents.find_all{ |o| o.results.size == 1 }.size # => 8
|
70
70
|
|
71
|
-
However, none of the opponents' results are rateable
|
71
|
+
However, none of the opponents' results are rateable because they are foreign to the domestic rating list
|
72
|
+
to which the main player belongs. For example:
|
72
73
|
|
73
74
|
opponent = tournament.players(2)
|
74
|
-
opponent.name
|
75
|
-
opponent.results[0].rateable
|
75
|
+
opponent.name # => "Taylor, Peter P."
|
76
|
+
opponent.results[0].rateable # => false
|
76
77
|
|
77
|
-
A tournament can be serialized back to CSV format (the reverse of parsing) with the
|
78
|
+
A tournament can be serialized back to CSV format (the reverse of parsing) with the _serialize_ method.
|
78
79
|
|
79
80
|
csv = parser.serialize(tournament)
|
80
81
|
|
@@ -140,7 +141,7 @@ A tournament can be serialized back to CSV format (the reverse of parsing) with
|
|
140
141
|
end
|
141
142
|
|
142
143
|
# Serialise a tournament back into CSV format.
|
143
|
-
def
|
144
|
+
def serialize(t)
|
144
145
|
return nil unless t.class == ICU::Tournament;
|
145
146
|
FasterCSV.generate do |csv|
|
146
147
|
csv << ["Event", t.name]
|
@@ -410,11 +410,11 @@ CSV
|
|
410
410
|
end
|
411
411
|
|
412
412
|
it "should serialize back to the original" do
|
413
|
-
@f.
|
413
|
+
@f.serialize(@t).should == @csv
|
414
414
|
end
|
415
415
|
|
416
416
|
it "should return nil on invalid input" do
|
417
|
-
@f.
|
417
|
+
@f.serialize('Rubbish').should be_nil
|
418
418
|
end
|
419
419
|
end
|
420
420
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sanichi-chess_icu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Orr
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|