chess 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +12 -0
- data/.github/workflows/ruby.yml +58 -0
- data/.gitignore +2 -2
- data/.rubocop.yml +9 -144
- data/Gemfile.lock +70 -0
- data/README.md +26 -22
- data/Rakefile +1 -0
- data/chess.gemspec +8 -5
- data/docs/Chess.html +157 -0
- data/docs/Chess/BadNotationError.html +237 -0
- data/docs/Chess/Board.html +1759 -0
- data/docs/Chess/CGame.html +2296 -0
- data/docs/Chess/Game.html +1277 -0
- data/docs/Chess/Gnuchess.html +366 -0
- data/docs/Chess/IllegalMoveError.html +137 -0
- data/docs/Chess/InvalidFenFormatError.html +237 -0
- data/docs/Chess/InvalidPgnFormatError.html +217 -0
- data/docs/Chess/Pgn.html +1477 -0
- data/docs/Chess/UTF8Notation.html +270 -0
- data/docs/_index.html +217 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +497 -0
- data/docs/file.README.html +116 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +116 -0
- data/docs/js/app.js +314 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +531 -0
- data/docs/top-level-namespace.html +110 -0
- data/ext/chess.c +1 -1
- data/ext/common.h +7 -3
- data/ext/extconf.rb +1 -1
- data/lib/chess/game.rb +53 -67
- data/lib/chess/gnuchess.rb +49 -53
- data/lib/chess/pgn.rb +10 -12
- data/lib/chess/utf8_notation.rb +3 -0
- data/lib/chess/version.rb +1 -1
- data/test/test_big_pgn_collection.rb +1 -1
- data/test/test_checkmate.rb +4 -4
- data/test/test_errors.rb +22 -0
- data/test/test_fifty_rule_move.rb +2 -2
- data/test/test_game.rb +82 -0
- data/test/test_helper.rb +15 -0
- data/test/test_insufficient_material.rb +4 -4
- data/test/test_move_generator.rb +3 -2
- data/test/test_pgn.rb +35 -0
- data/test/test_pgn_collection.rb +2 -2
- data/test/test_stalemate.rb +1 -1
- data/test/test_threefold_repetition.rb +1 -1
- metadata +112 -10
data/docs/Chess/Pgn.html
ADDED
@@ -0,0 +1,1477 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Chess::Pgn
|
8
|
+
|
9
|
+
— Chess
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "Chess::Pgn";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (P)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Chess.html" title="Chess (module)">Chess</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Pgn</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Chess::Pgn
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">Chess::Pgn</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/chess/pgn.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>Rappresents a game in PGN (Portable Game Notation) format.</p>
|
106
|
+
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<div class="tags">
|
111
|
+
|
112
|
+
|
113
|
+
</div>
|
114
|
+
|
115
|
+
<h2>
|
116
|
+
Constant Summary
|
117
|
+
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
|
118
|
+
</h2>
|
119
|
+
|
120
|
+
<dl class="constants">
|
121
|
+
|
122
|
+
<dt id="TAGS-constant" class="">TAGS =
|
123
|
+
<div class="docstring">
|
124
|
+
<div class="discussion">
|
125
|
+
|
126
|
+
<p>Array that include PGN standard tags.</p>
|
127
|
+
|
128
|
+
|
129
|
+
</div>
|
130
|
+
</div>
|
131
|
+
<div class="tags">
|
132
|
+
|
133
|
+
|
134
|
+
</div>
|
135
|
+
</dt>
|
136
|
+
<dd><pre class="code"><span class='qwords_beg'>%w[</span><span class='tstring_content'>event</span><span class='words_sep'> </span><span class='tstring_content'>site</span><span class='words_sep'> </span><span class='tstring_content'>date</span><span class='words_sep'> </span><span class='tstring_content'>round</span><span class='words_sep'> </span><span class='tstring_content'>white</span><span class='words_sep'> </span><span class='tstring_content'>black</span><span class='words_sep'> </span><span class='tstring_content'>result</span><span class='tstring_end'>]</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
137
|
+
|
138
|
+
</dl>
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
145
|
+
<ul class="summary">
|
146
|
+
|
147
|
+
<li class="public ">
|
148
|
+
<span class="summary_signature">
|
149
|
+
|
150
|
+
<a href="#black-instance_method" title="#black (instance method)">#<strong>black</strong> ⇒ String </a>
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
</span>
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
<span class="summary_desc"><div class='inline'>
|
168
|
+
<p>The player of the black pieces, same format as White.</p>
|
169
|
+
</div></span>
|
170
|
+
|
171
|
+
</li>
|
172
|
+
|
173
|
+
|
174
|
+
<li class="public ">
|
175
|
+
<span class="summary_signature">
|
176
|
+
|
177
|
+
<a href="#date-instance_method" title="#date (instance method)">#<strong>date</strong> ⇒ String </a>
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
</span>
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
<span class="summary_desc"><div class='inline'>
|
195
|
+
<p>The starting date of the game, in YYYY.MM.DD form.</p>
|
196
|
+
</div></span>
|
197
|
+
|
198
|
+
</li>
|
199
|
+
|
200
|
+
|
201
|
+
<li class="public ">
|
202
|
+
<span class="summary_signature">
|
203
|
+
|
204
|
+
<a href="#event-instance_method" title="#event (instance method)">#<strong>event</strong> ⇒ String </a>
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
</span>
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
<span class="summary_desc"><div class='inline'>
|
222
|
+
<p>The name of the tournament or match event.</p>
|
223
|
+
</div></span>
|
224
|
+
|
225
|
+
</li>
|
226
|
+
|
227
|
+
|
228
|
+
<li class="public ">
|
229
|
+
<span class="summary_signature">
|
230
|
+
|
231
|
+
<a href="#moves-instance_method" title="#moves (instance method)">#<strong>moves</strong> ⇒ Array<String> </a>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
</span>
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
<span class="summary_desc"><div class='inline'>
|
249
|
+
<p>The array with all moves done in short algebraic chess notation.</p>
|
250
|
+
</div></span>
|
251
|
+
|
252
|
+
</li>
|
253
|
+
|
254
|
+
|
255
|
+
<li class="public ">
|
256
|
+
<span class="summary_signature">
|
257
|
+
|
258
|
+
<a href="#result-instance_method" title="#result (instance method)">#<strong>result</strong> ⇒ String </a>
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
</span>
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
<span class="summary_desc"><div class='inline'>
|
276
|
+
<p>The result of the game.</p>
|
277
|
+
</div></span>
|
278
|
+
|
279
|
+
</li>
|
280
|
+
|
281
|
+
|
282
|
+
<li class="public ">
|
283
|
+
<span class="summary_signature">
|
284
|
+
|
285
|
+
<a href="#round-instance_method" title="#round (instance method)">#<strong>round</strong> ⇒ String </a>
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
</span>
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
<span class="summary_desc"><div class='inline'>
|
303
|
+
<p>The playing round ordinal of the game within the event.</p>
|
304
|
+
</div></span>
|
305
|
+
|
306
|
+
</li>
|
307
|
+
|
308
|
+
|
309
|
+
<li class="public ">
|
310
|
+
<span class="summary_signature">
|
311
|
+
|
312
|
+
<a href="#site-instance_method" title="#site (instance method)">#<strong>site</strong> ⇒ String </a>
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
</span>
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
<span class="summary_desc"><div class='inline'>
|
330
|
+
<p>The location of the event.</p>
|
331
|
+
</div></span>
|
332
|
+
|
333
|
+
</li>
|
334
|
+
|
335
|
+
|
336
|
+
<li class="public ">
|
337
|
+
<span class="summary_signature">
|
338
|
+
|
339
|
+
<a href="#white-instance_method" title="#white (instance method)">#<strong>white</strong> ⇒ String </a>
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
</span>
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
<span class="summary_desc"><div class='inline'>
|
357
|
+
<p>The player of the white pieces, in Lastname, Firstname format.</p>
|
358
|
+
</div></span>
|
359
|
+
|
360
|
+
</li>
|
361
|
+
|
362
|
+
|
363
|
+
</ul>
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
<h2>
|
370
|
+
Instance Method Summary
|
371
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
372
|
+
</h2>
|
373
|
+
|
374
|
+
<ul class="summary">
|
375
|
+
|
376
|
+
<li class="public ">
|
377
|
+
<span class="summary_signature">
|
378
|
+
|
379
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(filename = nil, check_moves: false) ⇒ Pgn </a>
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
</span>
|
384
|
+
|
385
|
+
|
386
|
+
<span class="note title constructor">constructor</span>
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
<span class="summary_desc"><div class='inline'>
|
396
|
+
<p>A new instance of Pgn.</p>
|
397
|
+
</div></span>
|
398
|
+
|
399
|
+
</li>
|
400
|
+
|
401
|
+
|
402
|
+
<li class="public ">
|
403
|
+
<span class="summary_signature">
|
404
|
+
|
405
|
+
<a href="#load-instance_method" title="#load (instance method)">#<strong>load</strong>(filename, check_moves: false) ⇒ Pgn </a>
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
</span>
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
<span class="summary_desc"><div class='inline'>
|
420
|
+
<p>Load a PGN from file.</p>
|
421
|
+
</div></span>
|
422
|
+
|
423
|
+
</li>
|
424
|
+
|
425
|
+
|
426
|
+
<li class="public ">
|
427
|
+
<span class="summary_signature">
|
428
|
+
|
429
|
+
<a href="#load_from_string-instance_method" title="#load_from_string (instance method)">#<strong>load_from_string</strong>(str, check_moves: false) ⇒ Pgn </a>
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
</span>
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
<span class="summary_desc"><div class='inline'>
|
444
|
+
<p>Load a PGN from string.</p>
|
445
|
+
</div></span>
|
446
|
+
|
447
|
+
</li>
|
448
|
+
|
449
|
+
|
450
|
+
<li class="public ">
|
451
|
+
<span class="summary_signature">
|
452
|
+
|
453
|
+
<a href="#to_s-instance_method" title="#to_s (instance method)">#<strong>to_s</strong> ⇒ Object </a>
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
</span>
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
<span class="summary_desc"><div class='inline'>
|
468
|
+
<p>PGN to string.</p>
|
469
|
+
</div></span>
|
470
|
+
|
471
|
+
</li>
|
472
|
+
|
473
|
+
|
474
|
+
<li class="public ">
|
475
|
+
<span class="summary_signature">
|
476
|
+
|
477
|
+
<a href="#write-instance_method" title="#write (instance method)">#<strong>write</strong>(filename) ⇒ Object </a>
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
</span>
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
<span class="summary_desc"><div class='inline'>
|
492
|
+
<p>Write PGN to file.</p>
|
493
|
+
</div></span>
|
494
|
+
|
495
|
+
</li>
|
496
|
+
|
497
|
+
|
498
|
+
</ul>
|
499
|
+
|
500
|
+
|
501
|
+
<div id="constructor_details" class="method_details_list">
|
502
|
+
<h2>Constructor Details</h2>
|
503
|
+
|
504
|
+
<div class="method_details first">
|
505
|
+
<h3 class="signature first" id="initialize-instance_method">
|
506
|
+
|
507
|
+
#<strong>initialize</strong>(filename = nil, check_moves: false) ⇒ <tt><span class='object_link'><a href="" title="Chess::Pgn (class)">Pgn</a></span></tt>
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
</h3><div class="docstring">
|
514
|
+
<div class="discussion">
|
515
|
+
|
516
|
+
<p>Returns a new instance of Pgn.</p>
|
517
|
+
|
518
|
+
|
519
|
+
</div>
|
520
|
+
</div>
|
521
|
+
<div class="tags">
|
522
|
+
<p class="tag_title">Parameters:</p>
|
523
|
+
<ul class="param">
|
524
|
+
|
525
|
+
<li>
|
526
|
+
|
527
|
+
<span class='name'>filename</span>
|
528
|
+
|
529
|
+
|
530
|
+
<span class='type'>(<tt>String</tt>)</span>
|
531
|
+
|
532
|
+
|
533
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
534
|
+
|
535
|
+
|
536
|
+
—
|
537
|
+
<div class='inline'>
|
538
|
+
<p>The path of the PGN file.</p>
|
539
|
+
</div>
|
540
|
+
|
541
|
+
</li>
|
542
|
+
|
543
|
+
<li>
|
544
|
+
|
545
|
+
<span class='name'>check_moves</span>
|
546
|
+
|
547
|
+
|
548
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
549
|
+
|
550
|
+
|
551
|
+
<em class="default">(defaults to: <tt>false</tt>)</em>
|
552
|
+
|
553
|
+
|
554
|
+
—
|
555
|
+
<div class='inline'>
|
556
|
+
<p>If true check if the moves are legal.</p>
|
557
|
+
</div>
|
558
|
+
|
559
|
+
</li>
|
560
|
+
|
561
|
+
</ul>
|
562
|
+
|
563
|
+
<p class="tag_title">Raises:</p>
|
564
|
+
<ul class="raise">
|
565
|
+
|
566
|
+
<li>
|
567
|
+
|
568
|
+
|
569
|
+
<span class='type'>(<tt><span class='object_link'><a href="InvalidPgnFormatError.html" title="Chess::InvalidPgnFormatError (class)">InvalidPgnFormatError</a></span></tt>)</span>
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
</li>
|
574
|
+
|
575
|
+
<li>
|
576
|
+
|
577
|
+
|
578
|
+
<span class='type'>(<tt><span class='object_link'><a href="IllegalMoveError.html" title="Chess::IllegalMoveError (class)">IllegalMoveError</a></span></tt>)</span>
|
579
|
+
|
580
|
+
|
581
|
+
|
582
|
+
</li>
|
583
|
+
|
584
|
+
</ul>
|
585
|
+
|
586
|
+
</div><table class="source_code">
|
587
|
+
<tr>
|
588
|
+
<td>
|
589
|
+
<pre class="lines">
|
590
|
+
|
591
|
+
|
592
|
+
40
|
593
|
+
41
|
594
|
+
42
|
595
|
+
43</pre>
|
596
|
+
</td>
|
597
|
+
<td>
|
598
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 40</span>
|
599
|
+
|
600
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>check_moves:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
601
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='label'>check_moves:</span> <span class='id identifier rubyid_check_moves'>check_moves</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_filename'>filename</span>
|
602
|
+
<span class='ivar'>@date</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>??</span><span class='tstring_end'>'</span></span>
|
603
|
+
<span class='kw'>end</span></pre>
|
604
|
+
</td>
|
605
|
+
</tr>
|
606
|
+
</table>
|
607
|
+
</div>
|
608
|
+
|
609
|
+
</div>
|
610
|
+
|
611
|
+
<div id="instance_attr_details" class="attr_details">
|
612
|
+
<h2>Instance Attribute Details</h2>
|
613
|
+
|
614
|
+
|
615
|
+
<span id="black=-instance_method"></span>
|
616
|
+
<div class="method_details first">
|
617
|
+
<h3 class="signature first" id="black-instance_method">
|
618
|
+
|
619
|
+
#<strong>black</strong> ⇒ <tt>String</tt>
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
|
625
|
+
</h3><div class="docstring">
|
626
|
+
<div class="discussion">
|
627
|
+
|
628
|
+
<p>The player of the black pieces, same format as White.</p>
|
629
|
+
|
630
|
+
|
631
|
+
</div>
|
632
|
+
</div>
|
633
|
+
<div class="tags">
|
634
|
+
|
635
|
+
<p class="tag_title">Returns:</p>
|
636
|
+
<ul class="return">
|
637
|
+
|
638
|
+
<li>
|
639
|
+
|
640
|
+
|
641
|
+
<span class='type'>(<tt>String</tt>)</span>
|
642
|
+
|
643
|
+
|
644
|
+
|
645
|
+
</li>
|
646
|
+
|
647
|
+
</ul>
|
648
|
+
|
649
|
+
</div><table class="source_code">
|
650
|
+
<tr>
|
651
|
+
<td>
|
652
|
+
<pre class="lines">
|
653
|
+
|
654
|
+
|
655
|
+
26
|
656
|
+
27
|
657
|
+
28</pre>
|
658
|
+
</td>
|
659
|
+
<td>
|
660
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 26</span>
|
661
|
+
|
662
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_black'>black</span>
|
663
|
+
<span class='ivar'>@black</span>
|
664
|
+
<span class='kw'>end</span></pre>
|
665
|
+
</td>
|
666
|
+
</tr>
|
667
|
+
</table>
|
668
|
+
</div>
|
669
|
+
|
670
|
+
|
671
|
+
<span id="date=-instance_method"></span>
|
672
|
+
<div class="method_details ">
|
673
|
+
<h3 class="signature " id="date-instance_method">
|
674
|
+
|
675
|
+
#<strong>date</strong> ⇒ <tt>String</tt>
|
676
|
+
|
677
|
+
|
678
|
+
|
679
|
+
|
680
|
+
|
681
|
+
</h3><div class="docstring">
|
682
|
+
<div class="discussion">
|
683
|
+
|
684
|
+
<p>The starting date of the game, in YYYY.MM.DD form. ?? is used for unknown values.</p>
|
685
|
+
|
686
|
+
|
687
|
+
</div>
|
688
|
+
</div>
|
689
|
+
<div class="tags">
|
690
|
+
|
691
|
+
<p class="tag_title">Returns:</p>
|
692
|
+
<ul class="return">
|
693
|
+
|
694
|
+
<li>
|
695
|
+
|
696
|
+
|
697
|
+
<span class='type'>(<tt>String</tt>)</span>
|
698
|
+
|
699
|
+
|
700
|
+
|
701
|
+
</li>
|
702
|
+
|
703
|
+
</ul>
|
704
|
+
|
705
|
+
</div><table class="source_code">
|
706
|
+
<tr>
|
707
|
+
<td>
|
708
|
+
<pre class="lines">
|
709
|
+
|
710
|
+
|
711
|
+
17
|
712
|
+
18
|
713
|
+
19</pre>
|
714
|
+
</td>
|
715
|
+
<td>
|
716
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 17</span>
|
717
|
+
|
718
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_date'>date</span>
|
719
|
+
<span class='ivar'>@date</span>
|
720
|
+
<span class='kw'>end</span></pre>
|
721
|
+
</td>
|
722
|
+
</tr>
|
723
|
+
</table>
|
724
|
+
</div>
|
725
|
+
|
726
|
+
|
727
|
+
<span id="event=-instance_method"></span>
|
728
|
+
<div class="method_details ">
|
729
|
+
<h3 class="signature " id="event-instance_method">
|
730
|
+
|
731
|
+
#<strong>event</strong> ⇒ <tt>String</tt>
|
732
|
+
|
733
|
+
|
734
|
+
|
735
|
+
|
736
|
+
|
737
|
+
</h3><div class="docstring">
|
738
|
+
<div class="discussion">
|
739
|
+
|
740
|
+
<p>The name of the tournament or match event.</p>
|
741
|
+
|
742
|
+
|
743
|
+
</div>
|
744
|
+
</div>
|
745
|
+
<div class="tags">
|
746
|
+
|
747
|
+
<p class="tag_title">Returns:</p>
|
748
|
+
<ul class="return">
|
749
|
+
|
750
|
+
<li>
|
751
|
+
|
752
|
+
|
753
|
+
<span class='type'>(<tt>String</tt>)</span>
|
754
|
+
|
755
|
+
|
756
|
+
|
757
|
+
</li>
|
758
|
+
|
759
|
+
</ul>
|
760
|
+
|
761
|
+
</div><table class="source_code">
|
762
|
+
<tr>
|
763
|
+
<td>
|
764
|
+
<pre class="lines">
|
765
|
+
|
766
|
+
|
767
|
+
9
|
768
|
+
10
|
769
|
+
11</pre>
|
770
|
+
</td>
|
771
|
+
<td>
|
772
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 9</span>
|
773
|
+
|
774
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_event'>event</span>
|
775
|
+
<span class='ivar'>@event</span>
|
776
|
+
<span class='kw'>end</span></pre>
|
777
|
+
</td>
|
778
|
+
</tr>
|
779
|
+
</table>
|
780
|
+
</div>
|
781
|
+
|
782
|
+
|
783
|
+
<span id="moves=-instance_method"></span>
|
784
|
+
<div class="method_details ">
|
785
|
+
<h3 class="signature " id="moves-instance_method">
|
786
|
+
|
787
|
+
#<strong>moves</strong> ⇒ <tt>Array<String></tt>
|
788
|
+
|
789
|
+
|
790
|
+
|
791
|
+
|
792
|
+
|
793
|
+
</h3><div class="docstring">
|
794
|
+
<div class="discussion">
|
795
|
+
|
796
|
+
<p>The array with all moves done in short algebraic chess notation.</p>
|
797
|
+
|
798
|
+
|
799
|
+
</div>
|
800
|
+
</div>
|
801
|
+
<div class="tags">
|
802
|
+
|
803
|
+
<p class="tag_title">Returns:</p>
|
804
|
+
<ul class="return">
|
805
|
+
|
806
|
+
<li>
|
807
|
+
|
808
|
+
|
809
|
+
<span class='type'>(<tt>Array<String></tt>)</span>
|
810
|
+
|
811
|
+
|
812
|
+
|
813
|
+
</li>
|
814
|
+
|
815
|
+
</ul>
|
816
|
+
|
817
|
+
</div><table class="source_code">
|
818
|
+
<tr>
|
819
|
+
<td>
|
820
|
+
<pre class="lines">
|
821
|
+
|
822
|
+
|
823
|
+
34
|
824
|
+
35
|
825
|
+
36</pre>
|
826
|
+
</td>
|
827
|
+
<td>
|
828
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 34</span>
|
829
|
+
|
830
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_moves'>moves</span>
|
831
|
+
<span class='ivar'>@moves</span>
|
832
|
+
<span class='kw'>end</span></pre>
|
833
|
+
</td>
|
834
|
+
</tr>
|
835
|
+
</table>
|
836
|
+
</div>
|
837
|
+
|
838
|
+
|
839
|
+
<span id="result=-instance_method"></span>
|
840
|
+
<div class="method_details ">
|
841
|
+
<h3 class="signature " id="result-instance_method">
|
842
|
+
|
843
|
+
#<strong>result</strong> ⇒ <tt>String</tt>
|
844
|
+
|
845
|
+
|
846
|
+
|
847
|
+
|
848
|
+
|
849
|
+
</h3><div class="docstring">
|
850
|
+
<div class="discussion">
|
851
|
+
|
852
|
+
<p>The result of the game. This can only have four possible values: 1-0 (White won), 0-1 (Black won), 1/2-1/2 (Draw), or * (other, e.g., the game is ongoing).</p>
|
853
|
+
|
854
|
+
|
855
|
+
</div>
|
856
|
+
</div>
|
857
|
+
<div class="tags">
|
858
|
+
|
859
|
+
<p class="tag_title">Returns:</p>
|
860
|
+
<ul class="return">
|
861
|
+
|
862
|
+
<li>
|
863
|
+
|
864
|
+
|
865
|
+
<span class='type'>(<tt>String</tt>)</span>
|
866
|
+
|
867
|
+
|
868
|
+
|
869
|
+
</li>
|
870
|
+
|
871
|
+
</ul>
|
872
|
+
|
873
|
+
</div><table class="source_code">
|
874
|
+
<tr>
|
875
|
+
<td>
|
876
|
+
<pre class="lines">
|
877
|
+
|
878
|
+
|
879
|
+
31
|
880
|
+
32
|
881
|
+
33</pre>
|
882
|
+
</td>
|
883
|
+
<td>
|
884
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 31</span>
|
885
|
+
|
886
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_result'>result</span>
|
887
|
+
<span class='ivar'>@result</span>
|
888
|
+
<span class='kw'>end</span></pre>
|
889
|
+
</td>
|
890
|
+
</tr>
|
891
|
+
</table>
|
892
|
+
</div>
|
893
|
+
|
894
|
+
|
895
|
+
<span id="round=-instance_method"></span>
|
896
|
+
<div class="method_details ">
|
897
|
+
<h3 class="signature " id="round-instance_method">
|
898
|
+
|
899
|
+
#<strong>round</strong> ⇒ <tt>String</tt>
|
900
|
+
|
901
|
+
|
902
|
+
|
903
|
+
|
904
|
+
|
905
|
+
</h3><div class="docstring">
|
906
|
+
<div class="discussion">
|
907
|
+
|
908
|
+
<p>The playing round ordinal of the game within the event.</p>
|
909
|
+
|
910
|
+
|
911
|
+
</div>
|
912
|
+
</div>
|
913
|
+
<div class="tags">
|
914
|
+
|
915
|
+
<p class="tag_title">Returns:</p>
|
916
|
+
<ul class="return">
|
917
|
+
|
918
|
+
<li>
|
919
|
+
|
920
|
+
|
921
|
+
<span class='type'>(<tt>String</tt>)</span>
|
922
|
+
|
923
|
+
|
924
|
+
|
925
|
+
</li>
|
926
|
+
|
927
|
+
</ul>
|
928
|
+
|
929
|
+
</div><table class="source_code">
|
930
|
+
<tr>
|
931
|
+
<td>
|
932
|
+
<pre class="lines">
|
933
|
+
|
934
|
+
|
935
|
+
20
|
936
|
+
21
|
937
|
+
22</pre>
|
938
|
+
</td>
|
939
|
+
<td>
|
940
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 20</span>
|
941
|
+
|
942
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_round'>round</span>
|
943
|
+
<span class='ivar'>@round</span>
|
944
|
+
<span class='kw'>end</span></pre>
|
945
|
+
</td>
|
946
|
+
</tr>
|
947
|
+
</table>
|
948
|
+
</div>
|
949
|
+
|
950
|
+
|
951
|
+
<span id="site=-instance_method"></span>
|
952
|
+
<div class="method_details ">
|
953
|
+
<h3 class="signature " id="site-instance_method">
|
954
|
+
|
955
|
+
#<strong>site</strong> ⇒ <tt>String</tt>
|
956
|
+
|
957
|
+
|
958
|
+
|
959
|
+
|
960
|
+
|
961
|
+
</h3><div class="docstring">
|
962
|
+
<div class="discussion">
|
963
|
+
|
964
|
+
<p>The location of the event. This is in City, Region COUNTRY format, where COUNTRY is the three-letter International Olympic Committee code for the country.</p>
|
965
|
+
|
966
|
+
|
967
|
+
</div>
|
968
|
+
</div>
|
969
|
+
<div class="tags">
|
970
|
+
|
971
|
+
<p class="tag_title">Returns:</p>
|
972
|
+
<ul class="return">
|
973
|
+
|
974
|
+
<li>
|
975
|
+
|
976
|
+
|
977
|
+
<span class='type'>(<tt>String</tt>)</span>
|
978
|
+
|
979
|
+
|
980
|
+
|
981
|
+
</li>
|
982
|
+
|
983
|
+
</ul>
|
984
|
+
|
985
|
+
</div><table class="source_code">
|
986
|
+
<tr>
|
987
|
+
<td>
|
988
|
+
<pre class="lines">
|
989
|
+
|
990
|
+
|
991
|
+
14
|
992
|
+
15
|
993
|
+
16</pre>
|
994
|
+
</td>
|
995
|
+
<td>
|
996
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 14</span>
|
997
|
+
|
998
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_site'>site</span>
|
999
|
+
<span class='ivar'>@site</span>
|
1000
|
+
<span class='kw'>end</span></pre>
|
1001
|
+
</td>
|
1002
|
+
</tr>
|
1003
|
+
</table>
|
1004
|
+
</div>
|
1005
|
+
|
1006
|
+
|
1007
|
+
<span id="white=-instance_method"></span>
|
1008
|
+
<div class="method_details ">
|
1009
|
+
<h3 class="signature " id="white-instance_method">
|
1010
|
+
|
1011
|
+
#<strong>white</strong> ⇒ <tt>String</tt>
|
1012
|
+
|
1013
|
+
|
1014
|
+
|
1015
|
+
|
1016
|
+
|
1017
|
+
</h3><div class="docstring">
|
1018
|
+
<div class="discussion">
|
1019
|
+
|
1020
|
+
<p>The player of the white pieces, in Lastname, Firstname format.</p>
|
1021
|
+
|
1022
|
+
|
1023
|
+
</div>
|
1024
|
+
</div>
|
1025
|
+
<div class="tags">
|
1026
|
+
|
1027
|
+
<p class="tag_title">Returns:</p>
|
1028
|
+
<ul class="return">
|
1029
|
+
|
1030
|
+
<li>
|
1031
|
+
|
1032
|
+
|
1033
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1034
|
+
|
1035
|
+
|
1036
|
+
|
1037
|
+
</li>
|
1038
|
+
|
1039
|
+
</ul>
|
1040
|
+
|
1041
|
+
</div><table class="source_code">
|
1042
|
+
<tr>
|
1043
|
+
<td>
|
1044
|
+
<pre class="lines">
|
1045
|
+
|
1046
|
+
|
1047
|
+
23
|
1048
|
+
24
|
1049
|
+
25</pre>
|
1050
|
+
</td>
|
1051
|
+
<td>
|
1052
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 23</span>
|
1053
|
+
|
1054
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_white'>white</span>
|
1055
|
+
<span class='ivar'>@white</span>
|
1056
|
+
<span class='kw'>end</span></pre>
|
1057
|
+
</td>
|
1058
|
+
</tr>
|
1059
|
+
</table>
|
1060
|
+
</div>
|
1061
|
+
|
1062
|
+
</div>
|
1063
|
+
|
1064
|
+
|
1065
|
+
<div id="instance_method_details" class="method_details_list">
|
1066
|
+
<h2>Instance Method Details</h2>
|
1067
|
+
|
1068
|
+
|
1069
|
+
<div class="method_details first">
|
1070
|
+
<h3 class="signature first" id="load-instance_method">
|
1071
|
+
|
1072
|
+
#<strong>load</strong>(filename, check_moves: false) ⇒ <tt><span class='object_link'><a href="" title="Chess::Pgn (class)">Pgn</a></span></tt>
|
1073
|
+
|
1074
|
+
|
1075
|
+
|
1076
|
+
|
1077
|
+
|
1078
|
+
</h3><div class="docstring">
|
1079
|
+
<div class="discussion">
|
1080
|
+
|
1081
|
+
<p>Load a PGN from file.</p>
|
1082
|
+
|
1083
|
+
|
1084
|
+
</div>
|
1085
|
+
</div>
|
1086
|
+
<div class="tags">
|
1087
|
+
<p class="tag_title">Parameters:</p>
|
1088
|
+
<ul class="param">
|
1089
|
+
|
1090
|
+
<li>
|
1091
|
+
|
1092
|
+
<span class='name'>filename</span>
|
1093
|
+
|
1094
|
+
|
1095
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1096
|
+
|
1097
|
+
|
1098
|
+
|
1099
|
+
—
|
1100
|
+
<div class='inline'>
|
1101
|
+
<p>The path of the PGN file.</p>
|
1102
|
+
</div>
|
1103
|
+
|
1104
|
+
</li>
|
1105
|
+
|
1106
|
+
<li>
|
1107
|
+
|
1108
|
+
<span class='name'>check_moves</span>
|
1109
|
+
|
1110
|
+
|
1111
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1112
|
+
|
1113
|
+
|
1114
|
+
<em class="default">(defaults to: <tt>false</tt>)</em>
|
1115
|
+
|
1116
|
+
|
1117
|
+
—
|
1118
|
+
<div class='inline'>
|
1119
|
+
<p>If true check if the moves are legal.</p>
|
1120
|
+
</div>
|
1121
|
+
|
1122
|
+
</li>
|
1123
|
+
|
1124
|
+
</ul>
|
1125
|
+
|
1126
|
+
<p class="tag_title">Returns:</p>
|
1127
|
+
<ul class="return">
|
1128
|
+
|
1129
|
+
<li>
|
1130
|
+
|
1131
|
+
|
1132
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Chess::Pgn (class)">Pgn</a></span></tt>)</span>
|
1133
|
+
|
1134
|
+
|
1135
|
+
|
1136
|
+
—
|
1137
|
+
<div class='inline'>
|
1138
|
+
<p>Returns <code>self</code>.</p>
|
1139
|
+
</div>
|
1140
|
+
|
1141
|
+
</li>
|
1142
|
+
|
1143
|
+
</ul>
|
1144
|
+
<p class="tag_title">Raises:</p>
|
1145
|
+
<ul class="raise">
|
1146
|
+
|
1147
|
+
<li>
|
1148
|
+
|
1149
|
+
|
1150
|
+
<span class='type'>(<tt><span class='object_link'><a href="InvalidPgnFormatError.html" title="Chess::InvalidPgnFormatError (class)">InvalidPgnFormatError</a></span></tt>)</span>
|
1151
|
+
|
1152
|
+
|
1153
|
+
|
1154
|
+
</li>
|
1155
|
+
|
1156
|
+
<li>
|
1157
|
+
|
1158
|
+
|
1159
|
+
<span class='type'>(<tt><span class='object_link'><a href="IllegalMoveError.html" title="Chess::IllegalMoveError (class)">IllegalMoveError</a></span></tt>)</span>
|
1160
|
+
|
1161
|
+
|
1162
|
+
|
1163
|
+
</li>
|
1164
|
+
|
1165
|
+
</ul>
|
1166
|
+
|
1167
|
+
</div><table class="source_code">
|
1168
|
+
<tr>
|
1169
|
+
<td>
|
1170
|
+
<pre class="lines">
|
1171
|
+
|
1172
|
+
|
1173
|
+
51
|
1174
|
+
52
|
1175
|
+
53
|
1176
|
+
54</pre>
|
1177
|
+
</td>
|
1178
|
+
<td>
|
1179
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 51</span>
|
1180
|
+
|
1181
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='label'>check_moves:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1182
|
+
<span class='id identifier rubyid_str'>str</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>r</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span>
|
1183
|
+
<span class='id identifier rubyid_load_from_string'>load_from_string</span><span class='lparen'>(</span><span class='id identifier rubyid_str'>str</span><span class='comma'>,</span> <span class='label'>check_moves:</span> <span class='id identifier rubyid_check_moves'>check_moves</span><span class='rparen'>)</span>
|
1184
|
+
<span class='kw'>end</span></pre>
|
1185
|
+
</td>
|
1186
|
+
</tr>
|
1187
|
+
</table>
|
1188
|
+
</div>
|
1189
|
+
|
1190
|
+
<div class="method_details ">
|
1191
|
+
<h3 class="signature " id="load_from_string-instance_method">
|
1192
|
+
|
1193
|
+
#<strong>load_from_string</strong>(str, check_moves: false) ⇒ <tt><span class='object_link'><a href="" title="Chess::Pgn (class)">Pgn</a></span></tt>
|
1194
|
+
|
1195
|
+
|
1196
|
+
|
1197
|
+
|
1198
|
+
|
1199
|
+
</h3><div class="docstring">
|
1200
|
+
<div class="discussion">
|
1201
|
+
|
1202
|
+
<p>Load a PGN from string.</p>
|
1203
|
+
|
1204
|
+
|
1205
|
+
</div>
|
1206
|
+
</div>
|
1207
|
+
<div class="tags">
|
1208
|
+
<p class="tag_title">Parameters:</p>
|
1209
|
+
<ul class="param">
|
1210
|
+
|
1211
|
+
<li>
|
1212
|
+
|
1213
|
+
<span class='name'>str</span>
|
1214
|
+
|
1215
|
+
|
1216
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1217
|
+
|
1218
|
+
|
1219
|
+
|
1220
|
+
—
|
1221
|
+
<div class='inline'>
|
1222
|
+
<p>The PGN string to load.</p>
|
1223
|
+
</div>
|
1224
|
+
|
1225
|
+
</li>
|
1226
|
+
|
1227
|
+
<li>
|
1228
|
+
|
1229
|
+
<span class='name'>check_moves</span>
|
1230
|
+
|
1231
|
+
|
1232
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1233
|
+
|
1234
|
+
|
1235
|
+
<em class="default">(defaults to: <tt>false</tt>)</em>
|
1236
|
+
|
1237
|
+
|
1238
|
+
—
|
1239
|
+
<div class='inline'>
|
1240
|
+
<p>If true check if the moves are legal.</p>
|
1241
|
+
</div>
|
1242
|
+
|
1243
|
+
</li>
|
1244
|
+
|
1245
|
+
</ul>
|
1246
|
+
|
1247
|
+
<p class="tag_title">Returns:</p>
|
1248
|
+
<ul class="return">
|
1249
|
+
|
1250
|
+
<li>
|
1251
|
+
|
1252
|
+
|
1253
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Chess::Pgn (class)">Pgn</a></span></tt>)</span>
|
1254
|
+
|
1255
|
+
|
1256
|
+
|
1257
|
+
—
|
1258
|
+
<div class='inline'>
|
1259
|
+
<p>Returns <code>self</code>.</p>
|
1260
|
+
</div>
|
1261
|
+
|
1262
|
+
</li>
|
1263
|
+
|
1264
|
+
</ul>
|
1265
|
+
<p class="tag_title">Raises:</p>
|
1266
|
+
<ul class="raise">
|
1267
|
+
|
1268
|
+
<li>
|
1269
|
+
|
1270
|
+
|
1271
|
+
<span class='type'>(<tt><span class='object_link'><a href="InvalidPgnFormatError.html" title="Chess::InvalidPgnFormatError (class)">InvalidPgnFormatError</a></span></tt>)</span>
|
1272
|
+
|
1273
|
+
|
1274
|
+
|
1275
|
+
</li>
|
1276
|
+
|
1277
|
+
<li>
|
1278
|
+
|
1279
|
+
|
1280
|
+
<span class='type'>(<tt><span class='object_link'><a href="IllegalMoveError.html" title="Chess::IllegalMoveError (class)">IllegalMoveError</a></span></tt>)</span>
|
1281
|
+
|
1282
|
+
|
1283
|
+
|
1284
|
+
</li>
|
1285
|
+
|
1286
|
+
</ul>
|
1287
|
+
|
1288
|
+
</div><table class="source_code">
|
1289
|
+
<tr>
|
1290
|
+
<td>
|
1291
|
+
<pre class="lines">
|
1292
|
+
|
1293
|
+
|
1294
|
+
62
|
1295
|
+
63
|
1296
|
+
64
|
1297
|
+
65
|
1298
|
+
66
|
1299
|
+
67
|
1300
|
+
68
|
1301
|
+
69
|
1302
|
+
70
|
1303
|
+
71
|
1304
|
+
72
|
1305
|
+
73
|
1306
|
+
74
|
1307
|
+
75
|
1308
|
+
76
|
1309
|
+
77
|
1310
|
+
78
|
1311
|
+
79</pre>
|
1312
|
+
</td>
|
1313
|
+
<td>
|
1314
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 62</span>
|
1315
|
+
|
1316
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_load_from_string'>load_from_string</span><span class='lparen'>(</span><span class='id identifier rubyid_str'>str</span><span class='comma'>,</span> <span class='label'>check_moves:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1317
|
+
<span class='id identifier rubyid_str'>str</span><span class='period'>.</span><span class='id identifier rubyid_gsub!'>gsub!</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\{.*?\}</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'># remove comments
|
1318
|
+
</span> <span class='const'><span class='object_link'><a href="#TAGS-constant" title="Chess::Pgn::TAGS (constant)">TAGS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_t'>t</span><span class='op'>|</span>
|
1319
|
+
<span class='id identifier rubyid_instance_variable_set'>instance_variable_set</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_t'>t</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_str'>str</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^\[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_t'>t</span><span class='period'>.</span><span class='id identifier rubyid_capitalize'>capitalize</span><span class='embexpr_end'>}</span><span class='tstring_content'> ".*"\]\s?$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span><span class='lbracket'>[</span><span class='id identifier rubyid_t'>t</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>+</span> <span class='int'>3</span><span class='op'>..</span><span class='op'>-</span><span class='int'>3</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
1320
|
+
<span class='kw'>end</span>
|
1321
|
+
<span class='ivar'>@result</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1/2-1/2</span><span class='tstring_end'>'</span></span> <span class='kw'>if</span> <span class='ivar'>@result</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1/2</span><span class='tstring_end'>'</span></span>
|
1322
|
+
<span class='id identifier rubyid_game_index'>game_index</span> <span class='op'>=</span> <span class='id identifier rubyid_str'>str</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^1\.</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span>
|
1323
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Chess.html" title="Chess (module)">Chess</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="InvalidPgnFormatError.html" title="Chess::InvalidPgnFormatError (class)">InvalidPgnFormatError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="InvalidPgnFormatError.html#initialize-instance_method" title="Chess::InvalidPgnFormatError#initialize (method)">new</a></span></span> <span class='kw'>if</span> <span class='id identifier rubyid_game_index'>game_index</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
1324
|
+
|
1325
|
+
<span class='id identifier rubyid_game'>game</span> <span class='op'>=</span> <span class='id identifier rubyid_str'>str</span><span class='lbracket'>[</span><span class='id identifier rubyid_game_index'>game_index</span><span class='op'>..</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span>
|
1326
|
+
<span class='ivar'>@moves</span> <span class='op'>=</span> <span class='id identifier rubyid_game'>game</span><span class='period'>.</span><span class='id identifier rubyid_tr'>tr</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'> </span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\d+\.</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:strip</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='op'>..</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:split</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span>
|
1327
|
+
<span class='ivar'>@moves</span><span class='period'>.</span><span class='id identifier rubyid_delete_at'>delete_at</span><span class='lparen'>(</span><span class='ivar'>@moves</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>-</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='ivar'>@moves</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='period'>.</span><span class='id identifier rubyid_match?'>match?</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(0-1)|(1-0)|(1\/2)|(1\/2-1\/2)|(\*)</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span>
|
1328
|
+
<span class='ivar'>@moves</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_m'>m</span><span class='op'>|</span>
|
1329
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Chess.html" title="Chess (module)">Chess</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="InvalidPgnFormatError.html" title="Chess::InvalidPgnFormatError (class)">InvalidPgnFormatError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="InvalidPgnFormatError.html#initialize-instance_method" title="Chess::InvalidPgnFormatError#initialize (method)">new</a></span></span> <span class='kw'>if</span> <span class='id identifier rubyid_m'>m</span> <span class='op'>!~</span> <span class='const'>MOVE_REGEXP</span> <span class='op'>&&</span> <span class='id identifier rubyid_m'>m</span> <span class='op'>!~</span> <span class='const'>SHORT_CASTLING_REGEXP</span> <span class='op'>&&</span> <span class='id identifier rubyid_m'>m</span> <span class='op'>!~</span> <span class='const'>LONG_CASTLING_REGEXP</span>
|
1330
|
+
<span class='kw'>end</span>
|
1331
|
+
<span class='const'><span class='object_link'><a href="../Chess.html" title="Chess (module)">Chess</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Game.html" title="Chess::Game (class)">Game</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Game.html#initialize-instance_method" title="Chess::Game#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='ivar'>@moves</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_check_moves'>check_moves</span>
|
1332
|
+
<span class='kw'>return</span> <span class='kw'>self</span>
|
1333
|
+
<span class='kw'>end</span></pre>
|
1334
|
+
</td>
|
1335
|
+
</tr>
|
1336
|
+
</table>
|
1337
|
+
</div>
|
1338
|
+
|
1339
|
+
<div class="method_details ">
|
1340
|
+
<h3 class="signature " id="to_s-instance_method">
|
1341
|
+
|
1342
|
+
#<strong>to_s</strong> ⇒ <tt>Object</tt>
|
1343
|
+
|
1344
|
+
|
1345
|
+
|
1346
|
+
|
1347
|
+
|
1348
|
+
</h3><div class="docstring">
|
1349
|
+
<div class="discussion">
|
1350
|
+
|
1351
|
+
<p>PGN to string.</p>
|
1352
|
+
|
1353
|
+
|
1354
|
+
</div>
|
1355
|
+
</div>
|
1356
|
+
<div class="tags">
|
1357
|
+
|
1358
|
+
|
1359
|
+
</div><table class="source_code">
|
1360
|
+
<tr>
|
1361
|
+
<td>
|
1362
|
+
<pre class="lines">
|
1363
|
+
|
1364
|
+
|
1365
|
+
82
|
1366
|
+
83
|
1367
|
+
84
|
1368
|
+
85
|
1369
|
+
86
|
1370
|
+
87
|
1371
|
+
88
|
1372
|
+
89
|
1373
|
+
90
|
1374
|
+
91
|
1375
|
+
92
|
1376
|
+
93
|
1377
|
+
94
|
1378
|
+
95
|
1379
|
+
96</pre>
|
1380
|
+
</td>
|
1381
|
+
<td>
|
1382
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 82</span>
|
1383
|
+
|
1384
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
|
1385
|
+
<span class='id identifier rubyid_s'>s</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
1386
|
+
<span class='const'><span class='object_link'><a href="#TAGS-constant" title="Chess::Pgn::TAGS (constant)">TAGS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_t'>t</span><span class='op'>|</span>
|
1387
|
+
<span class='id identifier rubyid_tag'>tag</span> <span class='op'>=</span> <span class='id identifier rubyid_instance_variable_defined?'>instance_variable_defined?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_t'>t</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_instance_variable_get'>instance_variable_get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_t'>t</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
1388
|
+
<span class='id identifier rubyid_s'>s</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_t'>t</span><span class='period'>.</span><span class='id identifier rubyid_capitalize'>capitalize</span><span class='embexpr_end'>}</span><span class='tstring_content'> \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_tag'>tag</span><span class='embexpr_end'>}</span><span class='tstring_content'>\"]\n</span><span class='tstring_end'>"</span></span>
|
1389
|
+
<span class='kw'>end</span>
|
1390
|
+
<span class='id identifier rubyid_s'>s</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span>
|
1391
|
+
<span class='id identifier rubyid_m'>m</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
1392
|
+
<span class='ivar'>@moves</span><span class='period'>.</span><span class='id identifier rubyid_each_with_index'>each_with_index</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_move'>move</span><span class='comma'>,</span> <span class='id identifier rubyid_i'>i</span><span class='op'>|</span>
|
1393
|
+
<span class='id identifier rubyid_m'>m</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_i'>i</span> <span class='op'>/</span> <span class='int'>2</span> <span class='op'>+</span> <span class='int'>1</span><span class='embexpr_end'>}</span><span class='tstring_content'>. </span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_even?'>even?</span>
|
1394
|
+
<span class='id identifier rubyid_m'>m</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_move'>move</span><span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='tstring_end'>"</span></span>
|
1395
|
+
<span class='kw'>end</span>
|
1396
|
+
<span class='id identifier rubyid_m'>m</span> <span class='op'><<</span> <span class='ivar'>@result</span> <span class='kw'>unless</span> <span class='ivar'>@result</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
1397
|
+
<span class='id identifier rubyid_s'>s</span> <span class='op'><<</span> <span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(.{1,78})(?: +|$)\n?|(.{78})</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\\1\\2\n</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1398
|
+
<span class='kw'>end</span></pre>
|
1399
|
+
</td>
|
1400
|
+
</tr>
|
1401
|
+
</table>
|
1402
|
+
</div>
|
1403
|
+
|
1404
|
+
<div class="method_details ">
|
1405
|
+
<h3 class="signature " id="write-instance_method">
|
1406
|
+
|
1407
|
+
#<strong>write</strong>(filename) ⇒ <tt>Object</tt>
|
1408
|
+
|
1409
|
+
|
1410
|
+
|
1411
|
+
|
1412
|
+
|
1413
|
+
</h3><div class="docstring">
|
1414
|
+
<div class="discussion">
|
1415
|
+
|
1416
|
+
<p>Write PGN to file.</p>
|
1417
|
+
|
1418
|
+
|
1419
|
+
</div>
|
1420
|
+
</div>
|
1421
|
+
<div class="tags">
|
1422
|
+
<p class="tag_title">Parameters:</p>
|
1423
|
+
<ul class="param">
|
1424
|
+
|
1425
|
+
<li>
|
1426
|
+
|
1427
|
+
<span class='name'>filename</span>
|
1428
|
+
|
1429
|
+
|
1430
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1431
|
+
|
1432
|
+
|
1433
|
+
|
1434
|
+
—
|
1435
|
+
<div class='inline'>
|
1436
|
+
<p>The path of the PGN file.</p>
|
1437
|
+
</div>
|
1438
|
+
|
1439
|
+
</li>
|
1440
|
+
|
1441
|
+
</ul>
|
1442
|
+
|
1443
|
+
|
1444
|
+
</div><table class="source_code">
|
1445
|
+
<tr>
|
1446
|
+
<td>
|
1447
|
+
<pre class="lines">
|
1448
|
+
|
1449
|
+
|
1450
|
+
100
|
1451
|
+
101
|
1452
|
+
102</pre>
|
1453
|
+
</td>
|
1454
|
+
<td>
|
1455
|
+
<pre class="code"><span class="info file"># File 'lib/chess/pgn.rb', line 100</span>
|
1456
|
+
|
1457
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='rparen'>)</span>
|
1458
|
+
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>w</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span> <span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
1459
|
+
<span class='kw'>end</span></pre>
|
1460
|
+
</td>
|
1461
|
+
</tr>
|
1462
|
+
</table>
|
1463
|
+
</div>
|
1464
|
+
|
1465
|
+
</div>
|
1466
|
+
|
1467
|
+
</div>
|
1468
|
+
|
1469
|
+
<div id="footer">
|
1470
|
+
Generated on Thu Jan 28 17:31:40 2021 by
|
1471
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1472
|
+
0.9.26 (ruby-2.6.1).
|
1473
|
+
</div>
|
1474
|
+
|
1475
|
+
</div>
|
1476
|
+
</body>
|
1477
|
+
</html>
|