chess 0.0.9 → 0.1.0
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 +0 -1
- data/Rakefile +1 -0
- data/doc/apple-touch-icon.png +0 -0
- data/doc/classes/Chess.html +162 -0
- data/doc/classes/Chess/BadNotationError.html +84 -0
- data/doc/classes/Chess/Board.html +795 -0
- data/doc/classes/Chess/CGame.html +1168 -0
- data/doc/classes/Chess/Game.html +775 -0
- data/doc/classes/Chess/Gnuchess.html +206 -0
- data/doc/classes/Chess/IllegalMoveError.html +82 -0
- data/doc/classes/Chess/InvalidFenFormatError.html +82 -0
- data/doc/classes/Chess/InvalidPgnFormatError.html +82 -0
- data/doc/classes/Chess/Pgn.html +332 -0
- data/doc/classes/Chess/UTF8Notation.html +175 -0
- data/doc/created.rid +15 -0
- data/doc/css/github.css +123 -0
- data/doc/css/main.css +323 -0
- data/doc/css/panel.css +384 -0
- data/doc/css/reset.css +48 -0
- data/doc/favicon.ico +0 -0
- data/doc/files/README_rdoc.html +122 -0
- data/doc/files/ext/bitboard_c.html +68 -0
- data/doc/files/ext/board_c.html +68 -0
- data/doc/files/ext/chess_c.html +68 -0
- data/doc/files/ext/common_c.html +68 -0
- data/doc/files/ext/game_c.html +68 -0
- data/doc/files/ext/special_c.html +68 -0
- data/doc/files/lib/chess/exceptions_rb.html +94 -0
- data/doc/files/lib/chess/game_rb.html +84 -0
- data/doc/files/lib/chess/gnuchess_rb.html +84 -0
- data/doc/files/lib/chess/pgn_rb.html +84 -0
- data/doc/files/lib/chess/utf8_notation_rb.html +84 -0
- data/doc/files/lib/chess/version_rb.html +85 -0
- data/doc/files/lib/chess_rb.html +84 -0
- data/doc/i/arrows.png +0 -0
- data/doc/i/results_bg.png +0 -0
- data/doc/i/tree_bg.png +0 -0
- data/doc/index.html +13 -0
- data/doc/js/highlight.pack.js +1 -0
- data/doc/js/jquery-1.3.2.min.js +19 -0
- data/doc/js/jquery-effect.js +593 -0
- data/doc/js/main.js +24 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searchdoc.js +449 -0
- data/doc/js/searcher.js +228 -0
- data/doc/panel/index.html +73 -0
- data/doc/panel/links.html +34 -0
- data/doc/panel/tree.js +1 -0
- data/ext/chess.c +82 -33
- data/ext/chess.h +1 -1
- data/ext/common.c +1 -1
- data/ext/common.h +1 -1
- data/ext/game.c +7 -6
- data/ext/game.h +1 -1
- data/lib/chess/exceptions.rb +2 -1
- data/lib/chess/game.rb +18 -5
- data/lib/chess/gnuchess.rb +1 -1
- data/lib/chess/utf8_notation.rb +1 -0
- data/lib/chess/version.rb +1 -1
- metadata +50 -3
@@ -0,0 +1,332 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<title>Chess::Pgn</title>
|
7
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
8
|
+
<link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
|
9
|
+
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
|
10
|
+
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
|
11
|
+
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
|
12
|
+
<script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
|
16
|
+
</head>
|
17
|
+
|
18
|
+
<body>
|
19
|
+
<div class="banner">
|
20
|
+
|
21
|
+
<h1>
|
22
|
+
<span class="type">Class</span>
|
23
|
+
Chess::Pgn
|
24
|
+
|
25
|
+
<span class="parent"><
|
26
|
+
|
27
|
+
Object
|
28
|
+
|
29
|
+
</span>
|
30
|
+
|
31
|
+
</h1>
|
32
|
+
<ul class="files">
|
33
|
+
|
34
|
+
<li><a href="../../files/lib/chess/pgn_rb.html">lib/chess/pgn.rb</a></li>
|
35
|
+
|
36
|
+
</ul>
|
37
|
+
</div>
|
38
|
+
<div id="bodyContent">
|
39
|
+
<div id="content">
|
40
|
+
|
41
|
+
<div class="description">
|
42
|
+
|
43
|
+
<p>Rappresents a game in PGN (Portable <a href="Game.html">Game</a> Notation)
|
44
|
+
format.</p>
|
45
|
+
|
46
|
+
</div>
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
<!-- Method ref -->
|
62
|
+
<div class="sectiontitle">Methods</div>
|
63
|
+
<dl class="methods">
|
64
|
+
|
65
|
+
<dt>L</dt>
|
66
|
+
<dd>
|
67
|
+
<ul>
|
68
|
+
|
69
|
+
|
70
|
+
<li>
|
71
|
+
<a href="#method-i-load">load</a>
|
72
|
+
</li>
|
73
|
+
|
74
|
+
</ul>
|
75
|
+
</dd>
|
76
|
+
|
77
|
+
<dt>N</dt>
|
78
|
+
<dd>
|
79
|
+
<ul>
|
80
|
+
|
81
|
+
|
82
|
+
<li>
|
83
|
+
<a href="#method-c-new">new</a>
|
84
|
+
</li>
|
85
|
+
|
86
|
+
</ul>
|
87
|
+
</dd>
|
88
|
+
|
89
|
+
<dt>T</dt>
|
90
|
+
<dd>
|
91
|
+
<ul>
|
92
|
+
|
93
|
+
|
94
|
+
<li>
|
95
|
+
<a href="#method-i-to_s">to_s</a>
|
96
|
+
</li>
|
97
|
+
|
98
|
+
</ul>
|
99
|
+
</dd>
|
100
|
+
|
101
|
+
<dt>W</dt>
|
102
|
+
<dd>
|
103
|
+
<ul>
|
104
|
+
|
105
|
+
|
106
|
+
<li>
|
107
|
+
<a href="#method-i-write">write</a>
|
108
|
+
</li>
|
109
|
+
|
110
|
+
</ul>
|
111
|
+
</dd>
|
112
|
+
|
113
|
+
</dl>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
<!-- Section constants -->
|
128
|
+
<div class="sectiontitle">Constants</div>
|
129
|
+
<table border='0' cellpadding='5'>
|
130
|
+
|
131
|
+
<tr valign='top'>
|
132
|
+
<td class="attr-name">TAGS</td>
|
133
|
+
<td>=</td>
|
134
|
+
<td class="attr-value">%w(event site date round white black result)</td>
|
135
|
+
</tr>
|
136
|
+
|
137
|
+
<tr valign='top'>
|
138
|
+
<td> </td>
|
139
|
+
<td colspan="2" class="attr-desc"><p>Array that include PGN standard tags.</p></td>
|
140
|
+
</tr>
|
141
|
+
|
142
|
+
|
143
|
+
</table>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
<!-- Methods -->
|
151
|
+
|
152
|
+
<div class="sectiontitle">Class Public methods</div>
|
153
|
+
|
154
|
+
<div class="method">
|
155
|
+
<div class="title method-title" id="method-c-new">
|
156
|
+
|
157
|
+
<b>new</b>(filename = nil)
|
158
|
+
|
159
|
+
<a href="../../classes/Chess/Pgn.html#method-c-new" name="method-c-new" class="permalink">Link</a>
|
160
|
+
</div>
|
161
|
+
|
162
|
+
|
163
|
+
<div class="description">
|
164
|
+
<p>Creates a new PGN. If param <code>filename</code>, load it from file.</p>
|
165
|
+
</div>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
<div class="sourcecode">
|
175
|
+
|
176
|
+
<p class="source-link">
|
177
|
+
Source:
|
178
|
+
<a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
|
179
|
+
|
180
|
+
</p>
|
181
|
+
<div id="method-c-new_source" class="dyn-source">
|
182
|
+
<pre><span class="ruby-comment"># File lib/chess/pgn.rb, line 12</span>
|
183
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>(<span class="ruby-identifier">filename</span> = <span class="ruby-keyword">nil</span>)
|
184
|
+
<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>
|
185
|
+
<span class="ruby-ivar">@date</span> = <span class="ruby-string">'??'</span>
|
186
|
+
<span class="ruby-ivar">@round</span> = <span class="ruby-string">'1'</span>
|
187
|
+
<span class="ruby-keyword">end</span></pre>
|
188
|
+
</div>
|
189
|
+
</div>
|
190
|
+
|
191
|
+
</div>
|
192
|
+
|
193
|
+
<div class="sectiontitle">Instance Public methods</div>
|
194
|
+
|
195
|
+
<div class="method">
|
196
|
+
<div class="title method-title" id="method-i-load">
|
197
|
+
|
198
|
+
<b>load</b>(filename)
|
199
|
+
|
200
|
+
<a href="../../classes/Chess/Pgn.html#method-i-load" name="method-i-load" class="permalink">Link</a>
|
201
|
+
</div>
|
202
|
+
|
203
|
+
|
204
|
+
<div class="description">
|
205
|
+
<p>Load a PGN from file.</p>
|
206
|
+
</div>
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
<div class="sourcecode">
|
216
|
+
|
217
|
+
<p class="source-link">
|
218
|
+
Source:
|
219
|
+
<a href="javascript:toggleSource('method-i-load_source')" id="l_method-i-load_source">show</a>
|
220
|
+
|
221
|
+
</p>
|
222
|
+
<div id="method-i-load_source" class="dyn-source">
|
223
|
+
<pre><span class="ruby-comment"># File lib/chess/pgn.rb, line 19</span>
|
224
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">load</span>(<span class="ruby-identifier">filename</span>)
|
225
|
+
<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>
|
226
|
+
<span class="ruby-identifier">data</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/\{.*?\}/</span>, <span class="ruby-string">''</span>)
|
227
|
+
<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>
|
228
|
+
<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-number">3</span><span class="ruby-operator">..</span><span class="ruby-number">-3</span>])
|
229
|
+
<span class="ruby-keyword">end</span>
|
230
|
+
<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>
|
231
|
+
<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>)
|
232
|
+
<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>
|
233
|
+
<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-number">-1</span>].<span class="ruby-identifier">strip</span>
|
234
|
+
<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-number">1</span><span class="ruby-operator">..</span><span class="ruby-number">-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>
|
235
|
+
<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-number">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>
|
236
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>
|
237
|
+
<span class="ruby-keyword">end</span></pre>
|
238
|
+
</div>
|
239
|
+
</div>
|
240
|
+
|
241
|
+
</div>
|
242
|
+
|
243
|
+
<div class="method">
|
244
|
+
<div class="title method-title" id="method-i-to_s">
|
245
|
+
|
246
|
+
<b>to_s</b>()
|
247
|
+
|
248
|
+
<a href="../../classes/Chess/Pgn.html#method-i-to_s" name="method-i-to_s" class="permalink">Link</a>
|
249
|
+
</div>
|
250
|
+
|
251
|
+
|
252
|
+
<div class="description">
|
253
|
+
<p>PGN to string.</p>
|
254
|
+
</div>
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<div class="sourcecode">
|
264
|
+
|
265
|
+
<p class="source-link">
|
266
|
+
Source:
|
267
|
+
<a href="javascript:toggleSource('method-i-to_s_source')" id="l_method-i-to_s_source">show</a>
|
268
|
+
|
269
|
+
</p>
|
270
|
+
<div id="method-i-to_s_source" class="dyn-source">
|
271
|
+
<pre><span class="ruby-comment"># File lib/chess/pgn.rb, line 35</span>
|
272
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">to_s</span>
|
273
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-string">''</span>
|
274
|
+
<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>
|
275
|
+
<span class="ruby-identifier">tag</span> = <span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-node">"@#{t}"</span>)
|
276
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"[#{t.capitalize} \"#{tag}\"]\n"</span>
|
277
|
+
<span class="ruby-keyword">end</span>
|
278
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-string">"\n"</span>
|
279
|
+
<span class="ruby-identifier">m</span> = <span class="ruby-string">''</span>
|
280
|
+
<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>
|
281
|
+
<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-number">2</span> <span class="ruby-operator">==</span> <span class="ruby-number">0</span>
|
282
|
+
<span class="ruby-identifier">m</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{move} "</span>
|
283
|
+
<span class="ruby-keyword">end</span>
|
284
|
+
<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>
|
285
|
+
<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>)
|
286
|
+
<span class="ruby-keyword">end</span></pre>
|
287
|
+
</div>
|
288
|
+
</div>
|
289
|
+
|
290
|
+
</div>
|
291
|
+
|
292
|
+
<div class="method">
|
293
|
+
<div class="title method-title" id="method-i-write">
|
294
|
+
|
295
|
+
<b>write</b>(filename)
|
296
|
+
|
297
|
+
<a href="../../classes/Chess/Pgn.html#method-i-write" name="method-i-write" class="permalink">Link</a>
|
298
|
+
</div>
|
299
|
+
|
300
|
+
|
301
|
+
<div class="description">
|
302
|
+
<p>Write PGN to file.</p>
|
303
|
+
</div>
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
<div class="sourcecode">
|
313
|
+
|
314
|
+
<p class="source-link">
|
315
|
+
Source:
|
316
|
+
<a href="javascript:toggleSource('method-i-write_source')" id="l_method-i-write_source">show</a>
|
317
|
+
|
318
|
+
</p>
|
319
|
+
<div id="method-i-write_source" class="dyn-source">
|
320
|
+
<pre><span class="ruby-comment"># File lib/chess/pgn.rb, line 52</span>
|
321
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">write</span>(<span class="ruby-identifier">filename</span>)
|
322
|
+
<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>) }
|
323
|
+
<span class="ruby-keyword">end</span></pre>
|
324
|
+
</div>
|
325
|
+
</div>
|
326
|
+
|
327
|
+
</div>
|
328
|
+
</div>
|
329
|
+
|
330
|
+
</div>
|
331
|
+
</body>
|
332
|
+
</html>
|
@@ -0,0 +1,175 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<title>Chess::UTF8Notation</title>
|
7
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
8
|
+
<link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
|
9
|
+
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
|
10
|
+
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
|
11
|
+
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
|
12
|
+
<script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
|
16
|
+
</head>
|
17
|
+
|
18
|
+
<body>
|
19
|
+
<div class="banner">
|
20
|
+
|
21
|
+
<h1>
|
22
|
+
<span class="type">Module</span>
|
23
|
+
Chess::UTF8Notation
|
24
|
+
|
25
|
+
</h1>
|
26
|
+
<ul class="files">
|
27
|
+
|
28
|
+
<li><a href="../../files/lib/chess/utf8_notation_rb.html">lib/chess/utf8_notation.rb</a></li>
|
29
|
+
|
30
|
+
</ul>
|
31
|
+
</div>
|
32
|
+
<div id="bodyContent">
|
33
|
+
<div id="content">
|
34
|
+
|
35
|
+
<div class="description">
|
36
|
+
|
37
|
+
<p>With this module is possible call the method <code>to_utf8</code> on a
|
38
|
+
string. This method convert the chess piece identifier character into UTF8
|
39
|
+
chess character, for example:</p>
|
40
|
+
|
41
|
+
<pre><code>:001 > require 'chess/utf8_notation'
|
42
|
+
=> true
|
43
|
+
:002 > 'Qf7#'.to_utf8
|
44
|
+
=> '♕f7#'</code></pre>
|
45
|
+
|
46
|
+
<p>To use this utility explicit require is needed: <code>require
|
47
|
+
'chess/utf8_notation'</code></p>
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
<!-- Method ref -->
|
65
|
+
<div class="sectiontitle">Methods</div>
|
66
|
+
<dl class="methods">
|
67
|
+
|
68
|
+
<dt>T</dt>
|
69
|
+
<dd>
|
70
|
+
<ul>
|
71
|
+
|
72
|
+
|
73
|
+
<li>
|
74
|
+
<a href="#method-i-to_utf8">to_utf8</a>
|
75
|
+
</li>
|
76
|
+
|
77
|
+
</ul>
|
78
|
+
</dd>
|
79
|
+
|
80
|
+
</dl>
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
<!-- Section constants -->
|
95
|
+
<div class="sectiontitle">Constants</div>
|
96
|
+
<table border='0' cellpadding='5'>
|
97
|
+
|
98
|
+
<tr valign='top'>
|
99
|
+
<td class="attr-name">UTF8_MAP</td>
|
100
|
+
<td>=</td>
|
101
|
+
<td class="attr-value">{
|
102
|
+
'P' => '♙',
|
103
|
+
'R' => '♖',
|
104
|
+
'N' => '♘',
|
105
|
+
'B' => '♗',
|
106
|
+
'Q' => '♕',
|
107
|
+
'K' => '♔',
|
108
|
+
'p' => '♟',
|
109
|
+
'r' => '♜',
|
110
|
+
'n' => '♞',
|
111
|
+
'b' => '♝',
|
112
|
+
'q' => '♛',
|
113
|
+
'k' => '♚'
|
114
|
+
}</td>
|
115
|
+
</tr>
|
116
|
+
|
117
|
+
<tr valign='top'>
|
118
|
+
<td> </td>
|
119
|
+
<td colspan="2" class="attr-desc"><p>Map a piece identifier character with the corresponding UTF8 chess
|
120
|
+
character</p></td>
|
121
|
+
</tr>
|
122
|
+
|
123
|
+
|
124
|
+
</table>
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
<!-- Methods -->
|
132
|
+
|
133
|
+
<div class="sectiontitle">Instance Public methods</div>
|
134
|
+
|
135
|
+
<div class="method">
|
136
|
+
<div class="title method-title" id="method-i-to_utf8">
|
137
|
+
|
138
|
+
<b>to_utf8</b>()
|
139
|
+
|
140
|
+
<a href="../../classes/Chess/UTF8Notation.html#method-i-to_utf8" name="method-i-to_utf8" class="permalink">Link</a>
|
141
|
+
</div>
|
142
|
+
|
143
|
+
|
144
|
+
<div class="description">
|
145
|
+
<p>Replace the piece identifier characters with UTF8 chess characters</p>
|
146
|
+
</div>
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
<div class="sourcecode">
|
156
|
+
|
157
|
+
<p class="source-link">
|
158
|
+
Source:
|
159
|
+
<a href="javascript:toggleSource('method-i-to_utf8_source')" id="l_method-i-to_utf8_source">show</a>
|
160
|
+
|
161
|
+
</p>
|
162
|
+
<div id="method-i-to_utf8_source" class="dyn-source">
|
163
|
+
<pre><span class="ruby-comment"># File lib/chess/utf8_notation.rb, line 33</span>
|
164
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">to_utf8</span>
|
165
|
+
<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>)
|
166
|
+
<span class="ruby-keyword">end</span></pre>
|
167
|
+
</div>
|
168
|
+
</div>
|
169
|
+
|
170
|
+
</div>
|
171
|
+
</div>
|
172
|
+
|
173
|
+
</div>
|
174
|
+
</body>
|
175
|
+
</html>
|