chess 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +44 -0
- data/Rakefile +6 -7
- data/chess.gemspec +1 -1
- data/ext/bitboard.c +24 -0
- data/ext/board.c +78 -24
- data/ext/board.h +4 -2
- data/ext/chess.c +216 -196
- data/ext/chess.h +1 -0
- data/ext/common.c +10 -0
- data/ext/game.c +33 -16
- data/ext/special.c +14 -11
- data/ext/special.h +1 -2
- data/lib/chess/exceptions.rb +7 -10
- data/lib/chess/game.rb +66 -50
- data/lib/chess/gnuchess.rb +19 -25
- data/lib/chess/pgn.rb +49 -9
- data/lib/chess/utf8_notation.rb +11 -9
- data/lib/chess/version.rb +1 -1
- data/test/pgn_collection/illegal/0001.pgn +18 -0
- data/test/pgn_collection/illegal/0002.pgn +17 -0
- data/test/pgn_collection/illegal/0003.pgn +13 -0
- data/test/pgn_collection/illegal/0004.pgn +15 -0
- data/test/pgn_collection/illegal/0005.pgn +16 -0
- data/test/pgn_collection/invalid/0001.pgn +20 -0
- data/test/pgn_collection/invalid/0002.pgn +16 -0
- data/test/pgn_collection/invalid/0003.pgn +13 -0
- data/test/pgn_collection/invalid/0004.pgn +15 -0
- data/test/pgn_collection/valid/0001.pgn +6 -7
- data/test/pgn_collection/valid/0002.pgn +8 -9
- data/test/pgn_collection/valid/0005.pgn +7 -8
- data/test/pgn_collection/valid/0009.pgn +14 -15
- data/test/pgn_collection/valid/0010.pgn +6 -7
- data/test/pgn_collection/valid/0011.pgn +5 -6
- data/test/pgn_collection/valid/0012.pgn +0 -1
- data/test/pgn_collection/valid/0013.pgn +5 -6
- data/test/pgn_collection/valid/0014.pgn +6 -7
- data/test/pgn_collection/valid/0020.pgn +6 -7
- data/test/pgn_collection/valid/0021.pgn +15 -16
- data/test/pgn_collection/valid/0971.pgn +22 -14
- data/test/test_big_pgn_collection.rb +12 -5
- data/test/test_helper.rb +1 -1
- data/test/test_illegal_moves.rb +14 -0
- data/test/test_insufficient_material.rb +13 -1
- data/test/test_particular_situations.rb +14 -0
- data/test/test_pgn.rb +24 -0
- data/test/test_pgn_collection.rb +1 -4
- metadata +30 -63
- data/README.rdoc +0 -44
- data/doc/Chess.html +0 -112
- data/doc/Chess/BadNotationError.html +0 -107
- data/doc/Chess/Board.html +0 -700
- data/doc/Chess/CGame.html +0 -1004
- data/doc/Chess/Game.html +0 -684
- data/doc/Chess/Gnuchess.html +0 -215
- data/doc/Chess/IllegalMoveError.html +0 -105
- data/doc/Chess/InvalidFenFormatError.html +0 -105
- data/doc/Chess/InvalidPgnFormatError.html +0 -105
- data/doc/Chess/Pgn.html +0 -309
- data/doc/Chess/UTF8Notation.html +0 -174
- data/doc/README_rdoc.html +0 -143
- data/doc/created.rid +0 -15
- data/doc/css/fonts.css +0 -167
- data/doc/css/rdoc.css +0 -590
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +0 -160
- data/doc/js/darkfish.js +0 -161
- data/doc/js/jquery.js +0 -4
- data/doc/js/navigation.js +0 -142
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search.js +0 -109
- data/doc/js/search_index.js +0 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +0 -229
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +0 -331
data/doc/Chess/Pgn.html
DELETED
@@ -1,309 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>class Chess::Pgn - Chess</title>
|
8
|
-
|
9
|
-
<script type="text/javascript">
|
10
|
-
var rdoc_rel_prefix = "../";
|
11
|
-
var index_rel_prefix = "../";
|
12
|
-
</script>
|
13
|
-
|
14
|
-
<script src="../js/jquery.js"></script>
|
15
|
-
<script src="../js/darkfish.js"></script>
|
16
|
-
|
17
|
-
<link href="../css/fonts.css" rel="stylesheet">
|
18
|
-
<link href="../css/rdoc.css" rel="stylesheet">
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<body id="top" role="document" class="class">
|
23
|
-
<nav role="navigation">
|
24
|
-
<div id="project-navigation">
|
25
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
26
|
-
<h2>
|
27
|
-
<a href="../index.html" rel="home">Home</a>
|
28
|
-
</h2>
|
29
|
-
|
30
|
-
<div id="table-of-contents-navigation">
|
31
|
-
<a href="../table_of_contents.html#pages">Pages</a>
|
32
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
33
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
34
|
-
</div>
|
35
|
-
</div>
|
36
|
-
|
37
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
38
|
-
<form action="#" method="get" accept-charset="utf-8">
|
39
|
-
<div id="search-field-wrapper">
|
40
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
41
|
-
aria-autocomplete="list" aria-controls="search-results"
|
42
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
43
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<ul id="search-results" aria-label="Search Results"
|
47
|
-
aria-busy="false" aria-expanded="false"
|
48
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
49
|
-
</form>
|
50
|
-
</div>
|
51
|
-
|
52
|
-
</div>
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
<div id="class-metadata">
|
57
|
-
|
58
|
-
<div id="parent-class-section" class="nav-section">
|
59
|
-
<h3>Parent</h3>
|
60
|
-
|
61
|
-
|
62
|
-
<p class="link">Object
|
63
|
-
|
64
|
-
</div>
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
<!-- Method Quickref -->
|
69
|
-
<div id="method-list-section" class="nav-section">
|
70
|
-
<h3>Methods</h3>
|
71
|
-
|
72
|
-
<ul class="link-list" role="directory">
|
73
|
-
|
74
|
-
<li ><a href="#method-c-new">::new</a>
|
75
|
-
|
76
|
-
<li ><a href="#method-i-load">#load</a>
|
77
|
-
|
78
|
-
<li ><a href="#method-i-to_s">#to_s</a>
|
79
|
-
|
80
|
-
<li ><a href="#method-i-write">#write</a>
|
81
|
-
|
82
|
-
</ul>
|
83
|
-
</div>
|
84
|
-
|
85
|
-
</div>
|
86
|
-
</nav>
|
87
|
-
|
88
|
-
<main role="main" aria-labelledby="class-Chess::Pgn">
|
89
|
-
<h1 id="class-Chess::Pgn" class="class">
|
90
|
-
class Chess::Pgn
|
91
|
-
</h1>
|
92
|
-
|
93
|
-
<section class="description">
|
94
|
-
|
95
|
-
<p>Rappresents a game in PGN (Portable <a href="Game.html">Game</a> Notation)
|
96
|
-
format.</p>
|
97
|
-
|
98
|
-
</section>
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
<section class="constants-list">
|
110
|
-
<header>
|
111
|
-
<h3>Constants</h3>
|
112
|
-
</header>
|
113
|
-
<dl>
|
114
|
-
|
115
|
-
<dt id="TAGS">TAGS
|
116
|
-
|
117
|
-
<dd><p>Array that include PGN standard tags.</p>
|
118
|
-
|
119
|
-
|
120
|
-
</dl>
|
121
|
-
</section>
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
128
|
-
<header>
|
129
|
-
<h3>Public Class Methods</h3>
|
130
|
-
</header>
|
131
|
-
|
132
|
-
|
133
|
-
<div id="method-c-new" class="method-detail ">
|
134
|
-
|
135
|
-
<div class="method-heading">
|
136
|
-
<span class="method-name">new</span><span
|
137
|
-
class="method-args">(filename = nil)</span>
|
138
|
-
|
139
|
-
<span class="method-click-advice">click to toggle source</span>
|
140
|
-
|
141
|
-
</div>
|
142
|
-
|
143
|
-
|
144
|
-
<div class="method-description">
|
145
|
-
|
146
|
-
<p>Creates a new PGN. If param <code>filename</code>, load it from file.</p>
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
<div class="method-source-code" id="new-source">
|
152
|
-
<pre><span class="ruby-comment"># File lib/chess/pgn.rb, line 12</span>
|
153
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">filename</span> = <span class="ruby-keyword">nil</span>)
|
154
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">filename</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">filename</span>
|
155
|
-
<span class="ruby-ivar">@date</span> = <span class="ruby-string">'??'</span>
|
156
|
-
<span class="ruby-ivar">@round</span> = <span class="ruby-string">'1'</span>
|
157
|
-
<span class="ruby-keyword">end</span></pre>
|
158
|
-
</div>
|
159
|
-
|
160
|
-
</div>
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
</div>
|
166
|
-
|
167
|
-
|
168
|
-
</section>
|
169
|
-
|
170
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
171
|
-
<header>
|
172
|
-
<h3>Public Instance Methods</h3>
|
173
|
-
</header>
|
174
|
-
|
175
|
-
|
176
|
-
<div id="method-i-load" class="method-detail ">
|
177
|
-
|
178
|
-
<div class="method-heading">
|
179
|
-
<span class="method-name">load</span><span
|
180
|
-
class="method-args">(filename)</span>
|
181
|
-
|
182
|
-
<span class="method-click-advice">click to toggle source</span>
|
183
|
-
|
184
|
-
</div>
|
185
|
-
|
186
|
-
|
187
|
-
<div class="method-description">
|
188
|
-
|
189
|
-
<p>Load a PGN from file.</p>
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
<div class="method-source-code" id="load-source">
|
195
|
-
<pre><span class="ruby-comment"># File lib/chess/pgn.rb, line 19</span>
|
196
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">load</span>(<span class="ruby-identifier">filename</span>)
|
197
|
-
<span class="ruby-identifier">data</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-string">'r'</span>).<span class="ruby-identifier">read</span>
|
198
|
-
<span class="ruby-identifier">data</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/\{.*?\}/</span>, <span class="ruby-string">''</span>)
|
199
|
-
<span class="ruby-constant">TAGS</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
|
200
|
-
<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">"@#{t}"</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">match</span>(<span class="ruby-node">/^\[#{t.capitalize} ".*"\]\s?$/</span>).<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">strip</span>[<span class="ruby-identifier">t</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">+</span><span class="ruby-value">3</span><span class="ruby-operator">..</span><span class="ruby-value">-3</span>])
|
201
|
-
<span class="ruby-keyword">end</span>
|
202
|
-
<span class="ruby-ivar">@result</span> = <span class="ruby-string">'1/2-1/2'</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@result</span> <span class="ruby-operator">==</span> <span class="ruby-string">'1/2'</span>
|
203
|
-
<span class="ruby-identifier">game_index</span> = <span class="ruby-identifier">data</span>.<span class="ruby-identifier">index</span>(<span class="ruby-regexp">/^1\./</span>)
|
204
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Chess</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidPgnFormatError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">filename</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">game_index</span>.<span class="ruby-identifier">nil?</span>
|
205
|
-
<span class="ruby-identifier">game</span> = <span class="ruby-identifier">data</span>[<span class="ruby-identifier">game_index</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">strip</span>
|
206
|
-
<span class="ruby-ivar">@moves</span> = <span class="ruby-identifier">game</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">"\n"</span>, <span class="ruby-string">' '</span>).<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\d+\./</span>).<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">strip</span>}[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">' '</span>)}.<span class="ruby-identifier">flatten</span>
|
207
|
-
<span class="ruby-ivar">@moves</span>.<span class="ruby-identifier">delete_at</span>(<span class="ruby-ivar">@moves</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@moves</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/(0-1)|(1-0)|(1\/2)|(1\/2-1\/2)|(\*)/</span>
|
208
|
-
<span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>
|
209
|
-
<span class="ruby-keyword">end</span></pre>
|
210
|
-
</div>
|
211
|
-
|
212
|
-
</div>
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
</div>
|
218
|
-
|
219
|
-
|
220
|
-
<div id="method-i-to_s" class="method-detail ">
|
221
|
-
|
222
|
-
<div class="method-heading">
|
223
|
-
<span class="method-name">to_s</span><span
|
224
|
-
class="method-args">()</span>
|
225
|
-
|
226
|
-
<span class="method-click-advice">click to toggle source</span>
|
227
|
-
|
228
|
-
</div>
|
229
|
-
|
230
|
-
|
231
|
-
<div class="method-description">
|
232
|
-
|
233
|
-
<p>PGN to string.</p>
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
<div class="method-source-code" id="to_s-source">
|
239
|
-
<pre><span class="ruby-comment"># File lib/chess/pgn.rb, line 35</span>
|
240
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">to_s</span>
|
241
|
-
<span class="ruby-identifier">s</span> = <span class="ruby-string">''</span>
|
242
|
-
<span class="ruby-constant">TAGS</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
|
243
|
-
<span class="ruby-identifier">tag</span> = <span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-node">"@#{t}"</span>)
|
244
|
-
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"[#{t.capitalize} \"#{tag}\"]\n"</span>
|
245
|
-
<span class="ruby-keyword">end</span>
|
246
|
-
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-string">"\n"</span>
|
247
|
-
<span class="ruby-identifier">m</span> = <span class="ruby-string">''</span>
|
248
|
-
<span class="ruby-ivar">@moves</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">move</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
249
|
-
<span class="ruby-identifier">m</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{i/2+1}. "</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">%</span> <span class="ruby-value">2</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
250
|
-
<span class="ruby-identifier">m</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{move} "</span>
|
251
|
-
<span class="ruby-keyword">end</span>
|
252
|
-
<span class="ruby-identifier">m</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@result</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@result</span>.<span class="ruby-identifier">nil?</span>
|
253
|
-
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/(.{1,78})(?: +|$)\n?|(.{78})/</span>, <span class="ruby-string">"\\1\\2\n"</span>)
|
254
|
-
<span class="ruby-keyword">end</span></pre>
|
255
|
-
</div>
|
256
|
-
|
257
|
-
</div>
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
</div>
|
263
|
-
|
264
|
-
|
265
|
-
<div id="method-i-write" class="method-detail ">
|
266
|
-
|
267
|
-
<div class="method-heading">
|
268
|
-
<span class="method-name">write</span><span
|
269
|
-
class="method-args">(filename)</span>
|
270
|
-
|
271
|
-
<span class="method-click-advice">click to toggle source</span>
|
272
|
-
|
273
|
-
</div>
|
274
|
-
|
275
|
-
|
276
|
-
<div class="method-description">
|
277
|
-
|
278
|
-
<p>Write PGN to file.</p>
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
<div class="method-source-code" id="write-source">
|
284
|
-
<pre><span class="ruby-comment"># File lib/chess/pgn.rb, line 52</span>
|
285
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">filename</span>)
|
286
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-string">'w'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">to_s</span>) }
|
287
|
-
<span class="ruby-keyword">end</span></pre>
|
288
|
-
</div>
|
289
|
-
|
290
|
-
</div>
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
</div>
|
296
|
-
|
297
|
-
|
298
|
-
</section>
|
299
|
-
|
300
|
-
</section>
|
301
|
-
</main>
|
302
|
-
|
303
|
-
|
304
|
-
<footer id="validator-badges" role="contentinfo">
|
305
|
-
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
306
|
-
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
307
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
308
|
-
</footer>
|
309
|
-
|
data/doc/Chess/UTF8Notation.html
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>module Chess::UTF8Notation - Chess</title>
|
8
|
-
|
9
|
-
<script type="text/javascript">
|
10
|
-
var rdoc_rel_prefix = "../";
|
11
|
-
var index_rel_prefix = "../";
|
12
|
-
</script>
|
13
|
-
|
14
|
-
<script src="../js/jquery.js"></script>
|
15
|
-
<script src="../js/darkfish.js"></script>
|
16
|
-
|
17
|
-
<link href="../css/fonts.css" rel="stylesheet">
|
18
|
-
<link href="../css/rdoc.css" rel="stylesheet">
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<body id="top" role="document" class="module">
|
23
|
-
<nav role="navigation">
|
24
|
-
<div id="project-navigation">
|
25
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
26
|
-
<h2>
|
27
|
-
<a href="../index.html" rel="home">Home</a>
|
28
|
-
</h2>
|
29
|
-
|
30
|
-
<div id="table-of-contents-navigation">
|
31
|
-
<a href="../table_of_contents.html#pages">Pages</a>
|
32
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
33
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
34
|
-
</div>
|
35
|
-
</div>
|
36
|
-
|
37
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
38
|
-
<form action="#" method="get" accept-charset="utf-8">
|
39
|
-
<div id="search-field-wrapper">
|
40
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
41
|
-
aria-autocomplete="list" aria-controls="search-results"
|
42
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
43
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<ul id="search-results" aria-label="Search Results"
|
47
|
-
aria-busy="false" aria-expanded="false"
|
48
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
49
|
-
</form>
|
50
|
-
</div>
|
51
|
-
|
52
|
-
</div>
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
<div id="class-metadata">
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
<!-- Method Quickref -->
|
62
|
-
<div id="method-list-section" class="nav-section">
|
63
|
-
<h3>Methods</h3>
|
64
|
-
|
65
|
-
<ul class="link-list" role="directory">
|
66
|
-
|
67
|
-
<li ><a href="#method-i-to_utf8">#to_utf8</a>
|
68
|
-
|
69
|
-
</ul>
|
70
|
-
</div>
|
71
|
-
|
72
|
-
</div>
|
73
|
-
</nav>
|
74
|
-
|
75
|
-
<main role="main" aria-labelledby="module-Chess::UTF8Notation">
|
76
|
-
<h1 id="module-Chess::UTF8Notation" class="module">
|
77
|
-
module Chess::UTF8Notation
|
78
|
-
</h1>
|
79
|
-
|
80
|
-
<section class="description">
|
81
|
-
|
82
|
-
<p>With this module is possible call the method <code>to_utf8</code> on a
|
83
|
-
string. This method convert the chess piece identifier character into UTF8
|
84
|
-
chess character, for example:</p>
|
85
|
-
|
86
|
-
<pre>:001 > require 'chess/utf8_notation'
|
87
|
-
=> true
|
88
|
-
:002 > 'Qf7#'.to_utf8
|
89
|
-
=> '♕f7#'</pre>
|
90
|
-
|
91
|
-
<p>To use this utility explicit require is needed: <code>require
|
92
|
-
'chess/utf8_notation'</code></p>
|
93
|
-
|
94
|
-
</section>
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
<section class="constants-list">
|
106
|
-
<header>
|
107
|
-
<h3>Constants</h3>
|
108
|
-
</header>
|
109
|
-
<dl>
|
110
|
-
|
111
|
-
<dt id="UTF8_MAP">UTF8_MAP
|
112
|
-
|
113
|
-
<dd><p>Map a piece identifier character with the corresponding UTF8 chess
|
114
|
-
character</p>
|
115
|
-
|
116
|
-
|
117
|
-
</dl>
|
118
|
-
</section>
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
125
|
-
<header>
|
126
|
-
<h3>Public Instance Methods</h3>
|
127
|
-
</header>
|
128
|
-
|
129
|
-
|
130
|
-
<div id="method-i-to_utf8" class="method-detail ">
|
131
|
-
|
132
|
-
<div class="method-heading">
|
133
|
-
<span class="method-name">to_utf8</span><span
|
134
|
-
class="method-args">()</span>
|
135
|
-
|
136
|
-
<span class="method-click-advice">click to toggle source</span>
|
137
|
-
|
138
|
-
</div>
|
139
|
-
|
140
|
-
|
141
|
-
<div class="method-description">
|
142
|
-
|
143
|
-
<p>Replace the piece identifier characters with UTF8 chess characters</p>
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
<div class="method-source-code" id="to_utf8-source">
|
149
|
-
<pre><span class="ruby-comment"># File lib/chess/utf8_notation.rb, line 33</span>
|
150
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">to_utf8</span>
|
151
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/[PRNBQKprnbqk]/</span>, <span class="ruby-constant">UTF8_MAP</span>)
|
152
|
-
<span class="ruby-keyword">end</span></pre>
|
153
|
-
</div>
|
154
|
-
|
155
|
-
</div>
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
</div>
|
161
|
-
|
162
|
-
|
163
|
-
</section>
|
164
|
-
|
165
|
-
</section>
|
166
|
-
</main>
|
167
|
-
|
168
|
-
|
169
|
-
<footer id="validator-badges" role="contentinfo">
|
170
|
-
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
171
|
-
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
172
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
173
|
-
</footer>
|
174
|
-
|