icu_tournament 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,132 +1,126 @@
1
1
  module ICU
2
2
  class Tournament
3
-
4
- =begin rdoc
5
-
6
- == Foreign CSV
7
-
8
- This is a format ({specification}[http://www.icu.ie/articles/display.php?id=172]) used by the ICU[http://icu.ie]
9
- for players to submit their individual results in foreign tournaments for domestic rating.
10
-
11
- Suppose, for example, that the following data is the file <em>tournament.csv</em>:
12
-
13
- Event,"Isle of Man Masters, 2007"
14
- Start,2007-09-22
15
- Rounds,9
16
- Website,http://www.bcmchess.co.uk/monarch2007/
17
-
18
- Player,456,Fox,Anthony
19
- 1,0,B,Taylor,Peter P.,2209,,ENG
20
- 2,=,W,Nadav,Egozi,2205,,ISR
21
- 3,=,B,Cafolla,Peter,2048,,IRL
22
- 4,1,W,Spanton,Tim R.,1982,,ENG
23
- 5,1,B,Grant,Alan,2223,,SCO
24
- 6,0,-
25
- 7,=,W,Walton,Alan J.,2223,,ENG
26
- 8,0,B,Bannink,Bernard,2271,FM,NED
27
- 9,=,W,Phillips,Roy,2271,,MAU
28
- Total,4
29
-
30
- This file can be parsed as follows.
31
-
32
- parser = ICU::Tournament::ForeignCSV.new
33
- tournament = parser.parse_file('tournament.csv')
34
-
35
- If the file is correctly specified, the return value from the <em>parse_file</em> method is an instance of
36
- ICU::Tournament (rather than <em>nil</em>, which indicates an error). In this example the file is valid, so:
37
-
38
- tournament.name # => "Isle of Man Masters, 2007"
39
- tournament.start # => "2007-09-22"
40
- tournament.rounds # => 9
41
- tournament.website # => "http://www.bcmchess.co.uk/monarch2007/"
42
-
43
- The main player (the player whose results are being reported for rating) played 9 rounds
44
- but only 8 other players (he had a bye in round 6), so the total number of players is 9.
45
-
46
- tournament.players.size # => 9
47
-
48
- 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.
49
-
50
- player = tournament.player(1)
51
- player.name # => "Fox, Anthony"
52
-
53
- This player has 4 points from 9 rounds but only 8 of his results are are rateable (because of the bye).
54
-
55
- player.points # => 4.0
56
- player.results.size # => 9
57
- player.results.find_all{ |r| r.rateable }.size # => 8
58
-
59
- The other players all have numbers greater than 1.
60
-
61
- opponents = tournamnet.players.reject { |o| o.num == 1 }
62
-
63
- There are 8 opponents (of the main player) each with exactly one game.
64
-
65
- opponents.size # => 8
66
- opponents.find_all{ |o| o.results.size == 1 }.size # => 8
67
-
68
- However, none of the opponents' results are rateable because they are foreign to the domestic rating list
69
- to which the main player belongs. For example:
70
-
71
- opponent = tournament.players(2)
72
- opponent.name # => "Taylor, Peter P."
73
- opponent.results[0].rateable # => false
74
-
75
- If the file contains errors, then the return value from <em>parse_file</em> is <em>nil</em> and
76
- an error message is returned by the <em>error</em> method of the parser object. The method
77
- <em>parse_file!</em> is similar except that it raises errors, and the methods <em>parse</em>
78
- and <em>parse!</em> are similar except their inputs are strings rather than file names.
79
-
80
- A tournament can be serialized back to CSV format (the reverse of parsing) with the _serialize_ method
81
- of the parser object.
82
-
83
- csv = parser.serialize(tournament)
84
-
85
- Or equivalently, the _serialize_ instance method of the tournament, if the appropriate parser name is supplied.
86
-
87
- csv = tournament.serialize('ForeignCSV')
88
-
89
- Extra condtions, over and above the normal validation rules, apply before any tournament validates or can be serialized in this format.
90
-
91
- * the tournament must have a _site_ attribute
92
- * there must be at least one player with an _id_ (interpreted as an ICU ID number)
93
- * all foreign players (those without an ICU ID) must have a _fed_ attribute (federation)
94
- * all ICU players must have a result in every round (even if it is just bye or is unrateable)
95
- * the opponents of all ICU players must have a federation (this could include other ICU players)
96
-
97
- If any of these are not satisfied, then the following method calls will all raise an exception:
98
-
99
- tournament.validate!(:type => 'ForeignCSV')
100
- tournament.serialize('ForeignCSV')
101
- ICU::Tournament::ForeignCSV.new.serialize(tournament)
102
-
103
- You can also build the tournament object from scratch using your own data and then serialize it.
104
- For example, here are the commands to reproduce the example above.
105
-
106
- t = ICU::Tournament.new("Isle of Man Masters, 2007", '2007-09-22', :rounds => 9)
107
- t.site = 'http://www.bcmchess.co.uk/monarch2007/'
108
- t.add_player(ICU::Player.new('Anthony', 'Fox', 1, :rating => 2100, :fed => 'IRL', :id => 456))
109
- t.add_player(ICU::Player.new('Peter P.', 'Taylor', 2, :rating => 2209, :fed => 'ENG'))
110
- t.add_player(ICU::Player.new('Egozi', 'Nadav', 3, :rating => 2205, :fed => 'ISR'))
111
- t.add_player(ICU::Player.new('Peter', 'Cafolla', 4, :rating => 2048, :fed => 'IRL'))
112
- t.add_player(ICU::Player.new('Tim R.', 'Spanton', 5, :rating => 1982, :fed => 'ENG'))
113
- t.add_player(ICU::Player.new('Alan', 'Grant', 6, :rating => 2223, :fed => 'SCO'))
114
- t.add_player(ICU::Player.new('Alan J.', 'Walton', 7, :rating => 2223, :fed => 'ENG'))
115
- t.add_player(ICU::Player.new('Bernard', 'Bannink', 8, :rating => 2271, :fed => 'NED', :title => 'FM'))
116
- t.add_player(ICU::Player.new('Roy', 'Phillips', 9, :rating => 2271, :fed => 'MAU'))
117
- t.add_result(ICU::Result.new(1, 1, 'L', :opponent => 2, :colour => 'B'))
118
- t.add_result(ICU::Result.new(2, 1, 'D', :opponent => 3, :colour => 'W'))
119
- t.add_result(ICU::Result.new(3, 1, 'D', :opponent => 4, :colour => 'B'))
120
- t.add_result(ICU::Result.new(4, 1, 'W', :opponent => 5, :colour => 'W'))
121
- t.add_result(ICU::Result.new(5, 1, 'W', :opponent => 6, :colour => 'B'))
122
- t.add_result(ICU::Result.new(6, 1, 'L'))
123
- t.add_result(ICU::Result.new(7, 1, 'D', :opponent => 7, :colour => 'W'))
124
- t.add_result(ICU::Result.new(8, 1, 'L', :opponent => 8, :colour => 'B'))
125
- t.add_result(ICU::Result.new(9, 1, 'D', :opponent => 9, :colour => 'W'))
126
- puts t.serialize('ForeignCSV')
127
-
128
- =end
129
-
3
+ #
4
+ # This is a format ({specification}[http://www.icu.ie/articles/display.php?id=172]) used by the ICU[http://icu.ie]
5
+ # for players to submit their individual results in foreign tournaments for domestic rating.
6
+ #
7
+ # Suppose, for example, that the following data is the file <em>tournament.csv</em>:
8
+ #
9
+ # Event,"Isle of Man Masters, 2007"
10
+ # Start,2007-09-22
11
+ # Rounds,9
12
+ # Website,http://www.bcmchess.co.uk/monarch2007/
13
+ #
14
+ # Player,456,Fox,Anthony
15
+ # 1,0,B,Taylor,Peter P.,2209,,ENG
16
+ # 2,=,W,Nadav,Egozi,2205,,ISR
17
+ # 3,=,B,Cafolla,Peter,2048,,IRL
18
+ # 4,1,W,Spanton,Tim R.,1982,,ENG
19
+ # 5,1,B,Grant,Alan,2223,,SCO
20
+ # 6,0,-
21
+ # 7,=,W,Walton,Alan J.,2223,,ENG
22
+ # 8,0,B,Bannink,Bernard,2271,FM,NED
23
+ # 9,=,W,Phillips,Roy,2271,,MAU
24
+ # Total,4
25
+ #
26
+ # This file can be parsed as follows.
27
+ #
28
+ # parser = ICU::Tournament::ForeignCSV.new
29
+ # tournament = parser.parse_file('tournament.csv')
30
+ #
31
+ # If the file is correctly specified, the return value from the <em>parse_file</em> method is an instance of
32
+ # ICU::Tournament (rather than <em>nil</em>, which indicates an error). In this example the file is valid, so:
33
+ #
34
+ # tournament.name # => "Isle of Man Masters, 2007"
35
+ # tournament.start # => "2007-09-22"
36
+ # tournament.rounds # => 9
37
+ # tournament.website # => "http://www.bcmchess.co.uk/monarch2007/"
38
+ #
39
+ # The main player (the player whose results are being reported for rating) played 9 rounds
40
+ # but only 8 other players (he had a bye in round 6), so the total number of players is 9.
41
+ #
42
+ # tournament.players.size # => 9
43
+ #
44
+ # 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.
45
+ #
46
+ # player = tournament.player(1)
47
+ # player.name # => "Fox, Anthony"
48
+ #
49
+ # This player has 4 points from 9 rounds but only 8 of his results are are rateable (because of the bye).
50
+ #
51
+ # player.points # => 4.0
52
+ # player.results.size # => 9
53
+ # player.results.find_all{ |r| r.rateable }.size # => 8
54
+ #
55
+ # The other players all have numbers greater than 1.
56
+ #
57
+ # opponents = tournamnet.players.reject { |o| o.num == 1 }
58
+ #
59
+ # There are 8 opponents (of the main player) each with exactly one game.
60
+ #
61
+ # opponents.size # => 8
62
+ # opponents.find_all{ |o| o.results.size == 1 }.size # => 8
63
+ #
64
+ # However, none of the opponents' results are rateable because they are foreign to the domestic rating list
65
+ # to which the main player belongs. For example:
66
+ #
67
+ # opponent = tournament.players(2)
68
+ # opponent.name # => "Taylor, Peter P."
69
+ # opponent.results[0].rateable # => false
70
+ #
71
+ # If the file contains errors, then the return value from <em>parse_file</em> is <em>nil</em> and
72
+ # an error message is returned by the <em>error</em> method of the parser object. The method
73
+ # <em>parse_file!</em> is similar except that it raises errors, and the methods <em>parse</em>
74
+ # and <em>parse!</em> are similar except their inputs are strings rather than file names.
75
+ #
76
+ # A tournament can be serialized back to CSV format (the reverse of parsing) with the _serialize_ method
77
+ # of the parser object.
78
+ #
79
+ # csv = parser.serialize(tournament)
80
+ #
81
+ # Or equivalently, the _serialize_ instance method of the tournament, if the appropriate parser name is supplied.
82
+ #
83
+ # csv = tournament.serialize('ForeignCSV')
84
+ #
85
+ # Extra condtions, over and above the normal validation rules, apply before any tournament validates or can be serialized in this format.
86
+ #
87
+ # * the tournament must have a _site_ attribute
88
+ # * there must be at least one player with an _id_ (interpreted as an ICU ID number)
89
+ # * all foreign players (those without an ICU ID) must have a _fed_ attribute (federation)
90
+ # * all ICU players must have a result in every round (even if it is just bye or is unrateable)
91
+ # * the opponents of all ICU players must have a federation (this could include other ICU players)
92
+ #
93
+ # If any of these are not satisfied, then the following method calls will all raise an exception:
94
+ #
95
+ # tournament.validate!(:type => 'ForeignCSV')
96
+ # tournament.serialize('ForeignCSV')
97
+ # ICU::Tournament::ForeignCSV.new.serialize(tournament)
98
+ #
99
+ # You can also build the tournament object from scratch using your own data and then serialize it.
100
+ # For example, here are the commands to reproduce the example above.
101
+ #
102
+ # t = ICU::Tournament.new("Isle of Man Masters, 2007", '2007-09-22', :rounds => 9)
103
+ # t.site = 'http://www.bcmchess.co.uk/monarch2007/'
104
+ # t.add_player(ICU::Player.new('Anthony', 'Fox', 1, :rating => 2100, :fed => 'IRL', :id => 456))
105
+ # t.add_player(ICU::Player.new('Peter P.', 'Taylor', 2, :rating => 2209, :fed => 'ENG'))
106
+ # t.add_player(ICU::Player.new('Egozi', 'Nadav', 3, :rating => 2205, :fed => 'ISR'))
107
+ # t.add_player(ICU::Player.new('Peter', 'Cafolla', 4, :rating => 2048, :fed => 'IRL'))
108
+ # t.add_player(ICU::Player.new('Tim R.', 'Spanton', 5, :rating => 1982, :fed => 'ENG'))
109
+ # t.add_player(ICU::Player.new('Alan', 'Grant', 6, :rating => 2223, :fed => 'SCO'))
110
+ # t.add_player(ICU::Player.new('Alan J.', 'Walton', 7, :rating => 2223, :fed => 'ENG'))
111
+ # t.add_player(ICU::Player.new('Bernard', 'Bannink', 8, :rating => 2271, :fed => 'NED', :title => 'FM'))
112
+ # t.add_player(ICU::Player.new('Roy', 'Phillips', 9, :rating => 2271, :fed => 'MAU'))
113
+ # t.add_result(ICU::Result.new(1, 1, 'L', :opponent => 2, :colour => 'B'))
114
+ # t.add_result(ICU::Result.new(2, 1, 'D', :opponent => 3, :colour => 'W'))
115
+ # t.add_result(ICU::Result.new(3, 1, 'D', :opponent => 4, :colour => 'B'))
116
+ # t.add_result(ICU::Result.new(4, 1, 'W', :opponent => 5, :colour => 'W'))
117
+ # t.add_result(ICU::Result.new(5, 1, 'W', :opponent => 6, :colour => 'B'))
118
+ # t.add_result(ICU::Result.new(6, 1, 'L'))
119
+ # t.add_result(ICU::Result.new(7, 1, 'D', :opponent => 7, :colour => 'W'))
120
+ # t.add_result(ICU::Result.new(8, 1, 'L', :opponent => 8, :colour => 'B'))
121
+ # t.add_result(ICU::Result.new(9, 1, 'D', :opponent => 9, :colour => 'W'))
122
+ # puts t.serialize('ForeignCSV')
123
+ #
130
124
  class ForeignCSV
131
125
  attr_reader :error
132
126
 
@@ -135,7 +129,7 @@ For example, here are the commands to reproduce the example above.
135
129
  @state, @line, @round, @sum, @error = 0, 0, nil, nil, nil
136
130
  @tournament = Tournament.new('Dummy', '2000-01-01')
137
131
 
138
- Util::CSV.parse(csv, :row_sep => :auto) do |r|
132
+ CSV.parse(csv, :row_sep => :auto) do |r|
139
133
  @line += 1 # increment line number
140
134
  next if r.size == 0 # skip empty lines
141
135
  r = r.map{|c| c.nil? ? '' : c.strip} # trim all spaces, turn nils to blanks
@@ -207,7 +201,7 @@ For example, here are the commands to reproduce the example above.
207
201
  # Serialise a tournament back into CSV format.
208
202
  def serialize(t, arg={})
209
203
  t.validate!(:type => self)
210
- Util::CSV.generate do |csv|
204
+ CSV.generate do |csv|
211
205
  csv << ["Event", t.name]
212
206
  csv << ["Start", t.start]
213
207
  csv << ["Rounds", t.rounds]
@@ -1,118 +1,112 @@
1
1
  module ICU
2
2
  class Tournament
3
-
4
- =begin rdoc
5
-
6
- == Krause
7
-
8
- This is the {format}[http://www.fide.com/component/content/article/5-whats-news/2245-736-general-data-exchange-format-for-tournament-results]
9
- used to submit tournament results to FIDE[http://www.fide.com] for rating.
10
-
11
- Suppose, for example, that the following data is the file <em>tournament.tab</em>:
12
-
13
- 012 Fantasy Tournament
14
- 032 IRL
15
- 042 2009.09.09
16
- 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
17
- 132 09.09.09 09.09.10 09.09.11
18
- 001 1 w Mouse,Minerva 1900 USA 1234567 1928.05.15 1.0 2 2 b 0 3 w 1
19
- 001 2 m m Duck,Daffy 2200 IRL 7654321 1937.04.17 2.0 1 1 w 1 3 b 1
20
- 001 3 m g Mouse,Mickey 2600 USA 1726354 1928.05.15 0.0 3 1 b 0 2 w 0
21
-
22
- This file can be parsed as follows.
23
-
24
- parser = ICU::Tournament::Krause.new
25
- tournament = parser.parse_file('tournament.tab')
26
-
27
- If the file is correctly specified, the return value from the <em>parse_file</em> method is an instance of
28
- ICU::Tournament (rather than <em>nil</em>, which indicates an error). In this example the file is valid, so:
29
-
30
- tournament.name # => "Fantasy Tournament"
31
- tournament.start # => "2009-09-09"
32
- tournament.fed # => "IRL"
33
- tournament.players.size # => 9
34
-
35
- Some values, not explicitly set in the file, are deduced:
36
-
37
- tournament.rounds # => 3
38
- tournament.finish # => "2009-09-11"
39
-
40
- A player can be retrieved from the tournament via the _players_ array or by sending a valid player number to the _player_ method.
41
-
42
- minnie = tournament.player(1)
43
- minnie.name # => "Mouse, Minerva"
44
- minnie.points # => 1.0
45
- minnie.results.size # => 2
46
-
47
- daffy = tournament.player(2)
48
- daffy.title # => "IM"
49
- daffy.rating # => 2200
50
- daffy.fed # => "IRL"
51
- daffy.id # => 7654321
52
- daffy.fide # => nil
53
- daffy.dob # => "1937-04-17"
54
-
55
- By default, ID numbers in the input are interpreted as local IDs. If, instead, they should be interpreted as
56
- FIDE IDs, add the following option:
57
-
58
- tournament = parser.parse_file('tournament.tab', :fide => true)
59
- daffy = tournament.player(2)
60
- daffy.id # => nil
61
- daffy.fide # => 7654321
62
-
63
- If the ranking numbers are missing from the file or inconsistent (e.g. player A is ranked above player B
64
- but has less points than player B) they are recalculated as a side effect of the parse.
65
-
66
- daffy.rank # => 1
67
- minnie.rank # => 2
68
- mickey.rank # => 3
69
-
70
- Comments in the input file (lines that do not start with a valid data identification number) are available from the parser
71
- instance via its _comments_ method (returning a string). Note that these comments are reset evry time the instance is used
72
- to parse another file.
73
-
74
- parser.comments # => "0123456789..."
75
-
76
- If the file contains errors, then the return value from <em>parse_file</em> is <em>nil</em> and
77
- an error message is returned by the <em>error</em> method of the parser object. The method
78
- <em>parse_file!</em> is similar except that it raises errors, and the methods <em>parse</em>
79
- and <em>parse!</em> are similar except their inputs are strings rather than file names.
80
-
81
- A tournament can be serialized back to Krause format (the reverse of parsing) with the _serialize_ method of the parser.
82
-
83
- krause = parser.serialize(tournament)
84
-
85
- Or alternatively, by the _serialize_ method of the tournament object if the name of the serializer is supplied.
86
-
87
- krause = tournament.serialize('Krause')
88
-
89
- By default, local (ICU) IDs are used for the serialization, but both methods accept an option that
90
- causes FIDE IDs to be used instead:
91
-
92
- krause = parser.serialize(tournament, :fide => true)
93
- krause = parser.serialize(tournament, :fide => true)
94
-
95
- The following lists Krause data identification numbers, their description and, where available, their corresponding
96
- attributes in an ICU::Tournament instance.
97
-
98
- [001 Player record] Use _players_ to get all players or _player_ with a player number to get a single instance.
99
- [012 Name] Get or set with _name_. Free text. A tounament name is mandatory.
100
- [013 Teams] Create an ICU::Team, add player numbers to it, use _add_team_ to add to tournament, _get_team_/_teams_ to retrive it/them.
101
- [022 City] Get or set with _city_. Free text.
102
- [032 Federation] Get or set with _fed_. Getter returns either _nil_ or a three letter code. Setter can take various formats (see ICU::Federation).
103
- [042 Start date] Get or set with _start_. Getter returns <em>yyyy-mm-dd</em> format, but setter can use any reasonable date format. Start date is mandadory.
104
- [052 End date] Get or set with _finish_. Returns either <em>yyyy-mm-dd</em> format or _nil_ if not set. Like _start_, can be set with various date formats.
105
- [062 Number of players] Not used. Treated as comment in parsed files. Can be determined from the size of the _players_ array.
106
- [072 Number of rated players] Not used. Treated as comment in parsed files. Can be determined by analysing the array returned by _players_.
107
- [082 Number of teams] Not used. Treated as comment in parsed files.
108
- [092 Type of tournament] Get or set with _type_. Free text.
109
- [102 Arbiter(s)] Get or set with -arbiter_. Free text.
110
- [112 Deputy(ies)] Get or set with _deputy_. Free text.
111
- [122 Time control] Get or set with _time_control_. Free text.
112
- [132 Round dates] Get an array of dates using _round_dates_ or one specific round date by calling _round_date_ with a round number.
113
-
114
- =end
115
-
3
+ #
4
+ # This is the {format}[http://www.fide.com/component/content/article/5-whats-news/2245-736-general-data-exchange-format-for-tournament-results]
5
+ # used to submit tournament results to FIDE[http://www.fide.com] for rating.
6
+ #
7
+ # Suppose, for example, that the following data is the file <em>tournament.tab</em>:
8
+ #
9
+ # 012 Fantasy Tournament
10
+ # 032 IRL
11
+ # 042 2009.09.09
12
+ # 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
13
+ # 132 09.09.09 09.09.10 09.09.11
14
+ # 001 1 w Mouse,Minerva 1900 USA 1234567 1928.05.15 1.0 2 2 b 0 3 w 1
15
+ # 001 2 m m Duck,Daffy 2200 IRL 7654321 1937.04.17 2.0 1 1 w 1 3 b 1
16
+ # 001 3 m g Mouse,Mickey 2600 USA 1726354 1928.05.15 0.0 3 1 b 0 2 w 0
17
+ #
18
+ # This file can be parsed as follows.
19
+ #
20
+ # parser = ICU::Tournament::Krause.new
21
+ # tournament = parser.parse_file('tournament.tab')
22
+ #
23
+ # If the file is correctly specified, the return value from the <em>parse_file</em> method is an instance of
24
+ # ICU::Tournament (rather than <em>nil</em>, which indicates an error). In this example the file is valid, so:
25
+ #
26
+ # tournament.name # => "Fantasy Tournament"
27
+ # tournament.start # => "2009-09-09"
28
+ # tournament.fed # => "IRL"
29
+ # tournament.players.size # => 9
30
+ #
31
+ # Some values, not explicitly set in the file, are deduced:
32
+ #
33
+ # tournament.rounds # => 3
34
+ # tournament.finish # => "2009-09-11"
35
+ #
36
+ # A player can be retrieved from the tournament via the _players_ array or by sending a valid player number to the _player_ method.
37
+ #
38
+ # minnie = tournament.player(1)
39
+ # minnie.name # => "Mouse, Minerva"
40
+ # minnie.points # => 1.0
41
+ # minnie.results.size # => 2
42
+ #
43
+ # daffy = tournament.player(2)
44
+ # daffy.title # => "IM"
45
+ # daffy.rating # => 2200
46
+ # daffy.fed # => "IRL"
47
+ # daffy.id # => 7654321
48
+ # daffy.fide # => nil
49
+ # daffy.dob # => "1937-04-17"
50
+ #
51
+ # By default, ID numbers in the input are interpreted as local IDs. If, instead, they should be interpreted as
52
+ # FIDE IDs, add the following option:
53
+ #
54
+ # tournament = parser.parse_file('tournament.tab', :fide => true)
55
+ # daffy = tournament.player(2)
56
+ # daffy.id # => nil
57
+ # daffy.fide # => 7654321
58
+ #
59
+ # If the ranking numbers are missing from the file or inconsistent (e.g. player A is ranked above player B
60
+ # but has less points than player B) they are recalculated as a side effect of the parse.
61
+ #
62
+ # daffy.rank # => 1
63
+ # minnie.rank # => 2
64
+ # mickey.rank # => 3
65
+ #
66
+ # Comments in the input file (lines that do not start with a valid data identification number) are available from the parser
67
+ # instance via its _comments_ method (returning a string). Note that these comments are reset evry time the instance is used
68
+ # to parse another file.
69
+ #
70
+ # parser.comments # => "0123456789..."
71
+ #
72
+ # If the file contains errors, then the return value from <em>parse_file</em> is <em>nil</em> and
73
+ # an error message is returned by the <em>error</em> method of the parser object. The method
74
+ # <em>parse_file!</em> is similar except that it raises errors, and the methods <em>parse</em>
75
+ # and <em>parse!</em> are similar except their inputs are strings rather than file names.
76
+ #
77
+ # A tournament can be serialized back to Krause format (the reverse of parsing) with the _serialize_ method of the parser.
78
+ #
79
+ # krause = parser.serialize(tournament)
80
+ #
81
+ # Or alternatively, by the _serialize_ method of the tournament object if the name of the serializer is supplied.
82
+ #
83
+ # krause = tournament.serialize('Krause')
84
+ #
85
+ # By default, local (ICU) IDs are used for the serialization, but both methods accept an option that
86
+ # causes FIDE IDs to be used instead:
87
+ #
88
+ # krause = parser.serialize(tournament, :fide => true)
89
+ # krause = parser.serialize(tournament, :fide => true)
90
+ #
91
+ # The following lists Krause data identification numbers, their description and, where available, their corresponding
92
+ # attributes in an ICU::Tournament instance.
93
+ #
94
+ # [001 Player record] Use _players_ to get all players or _player_ with a player number to get a single instance.
95
+ # [012 Name] Get or set with _name_. Free text. A tounament name is mandatory.
96
+ # [013 Teams] Create an ICU::Team, add player numbers to it, use _add_team_ to add to tournament, _get_team_/_teams_ to retrive it/them.
97
+ # [022 City] Get or set with _city_. Free text.
98
+ # [032 Federation] Get or set with _fed_. Getter returns either _nil_ or a three letter code. Setter can take various formats (see ICU::Federation).
99
+ # [042 Start date] Get or set with _start_. Getter returns <em>yyyy-mm-dd</em> format, but setter can use any reasonable date format. Start date is mandadory.
100
+ # [052 End date] Get or set with _finish_. Returns either <em>yyyy-mm-dd</em> format or _nil_ if not set. Like _start_, can be set with various date formats.
101
+ # [062 Number of players] Not used. Treated as comment in parsed files. Can be determined from the size of the _players_ array.
102
+ # [072 Number of rated players] Not used. Treated as comment in parsed files. Can be determined by analysing the array returned by _players_.
103
+ # [082 Number of teams] Not used. Treated as comment in parsed files.
104
+ # [092 Type of tournament] Get or set with _type_. Free text.
105
+ # [102 Arbiter(s)] Get or set with -arbiter_. Free text.
106
+ # [112 Deputy(ies)] Get or set with _deputy_. Free text.
107
+ # [122 Time control] Get or set with _time_control_. Free text.
108
+ # [132 Round dates] Get an array of dates using _round_dates_ or one specific round date by calling _round_date_ with a round number.
109
+ #
116
110
  class Krause
117
111
  attr_reader :error, :comments
118
112