chess_openings 0.0.3 → 1.0.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.
@@ -0,0 +1,241 @@
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
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.7
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "README";
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="file_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</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><h1>Chess Openings</h1>
61
+
62
+ <p>Ruby gem that where you can manipulate, search for and get information from chess openings.</p>
63
+
64
+ <h2>TODOS:</h2>
65
+
66
+ <ul>
67
+ <li>Write documentation</li>
68
+ </ul>
69
+
70
+ <h2>Features:</h2>
71
+
72
+ <ul>
73
+ <li>Get opening from PGN file</li>
74
+ <li>Get opening from PGN string</li>
75
+ <li>Get opening from array with moves</li>
76
+ <li>Get opening from FEN</li>
77
+ <li>Search opening by name</li>
78
+ <li>Get all openings</li>
79
+ <li>Get all openings that start with some determined moves</li>
80
+ <li>Get PGN string from an opening</li>
81
+ <li>Get FEN from an opening</li>
82
+ </ul>
83
+
84
+ <h2>Installation</h2>
85
+
86
+ <p>Add this line to your application&#39;s Gemfile:</p>
87
+
88
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>chess_openings</span><span class='tstring_end'>&#39;</span></span>
89
+ </code></pre>
90
+
91
+ <p>And then execute:</p>
92
+
93
+ <pre class="code ruby"><code class="ruby">$ bundle
94
+ </code></pre>
95
+
96
+ <p>Or install it yourself as:</p>
97
+
98
+ <pre class="code ruby"><code class="ruby">$ gem install chess_openings
99
+ </code></pre>
100
+
101
+ <h2>Usage</h2>
102
+
103
+ <p>First things first, you need to create a new ChessOpenings object:</p>
104
+
105
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
106
+ </code></pre>
107
+
108
+ <p>From here you can use several functions:</p>
109
+
110
+ <h4>.from_pgn</h4>
111
+
112
+ <p>Get opening from PGN file</p>
113
+
114
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
115
+ <span class='id identifier rubyid_opening'>opening</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_from_pgn'>from_pgn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>path_to/pgn_game.pgn</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
116
+ <span class='comment'>#=&gt; #&lt;Opening:0x007fda6237b510 @name=&quot;English, Sicilian reversed&quot;, @eco_code=&quot;A25&quot;, @moves=[:c4, :e5, :Nc3, :Nc6]&gt;
117
+ </span></code></pre>
118
+
119
+ <h4>.from_string</h4>
120
+
121
+ <p>Get opening from a string, formated like a PGN file</p>
122
+
123
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
124
+ <span class='id identifier rubyid_opening'>opening</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_from_string'>from_string</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>1.e4 e5 2.Nf3 Nc6 3.Bb5 a6 4.Bxc6</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
125
+ <span class='comment'>#=&gt; #&lt;Opening:0x007f820961bf60 @name=&quot;Ruy Lopez, exchange variation&quot;, @eco_code=&quot;C68&quot;, @moves=[:e4, :e5, :Nf3, :Nc6, :Bb5, :a6, :Bxc6]&gt;
126
+ </span></code></pre>
127
+
128
+ <h4>.from_moves</h4>
129
+
130
+ <p>Get opening from an array with moves (as symbols or strings)</p>
131
+
132
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
133
+ <span class='id identifier rubyid_opening'>opening</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_from_moves'>from_moves</span> <span class='lbracket'>[</span><span class='symbol'>:e4</span><span class='comma'>,</span> <span class='symbol'>:c6</span><span class='comma'>,</span> <span class='symbol'>:d4</span><span class='comma'>,</span> <span class='symbol'>:d5</span><span class='rbracket'>]</span>
134
+ <span class='comment'>#=&gt; #&lt;Opening:0x007f8209d9c910 @name=&quot;Caro-Kann defence&quot;, @eco_code=&quot;B12&quot;, @moves=[:e4, :c6, :d4, :d5]&gt;
135
+ </span></code></pre>
136
+
137
+ <h4>.with_name</h4>
138
+
139
+ <p>Search openings by name</p>
140
+
141
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
142
+ <span class='id identifier rubyid_openings'>openings</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_with_name'>with_name</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>alekhine defence</span><span class='tstring_end'>&quot;</span></span>
143
+ <span class='embdoc_beg'>=begin
144
+ </span><span class='embdoc'>[
145
+ </span><span class='embdoc'> [ 0] #&lt;Opening:0x007f8209de8a18 @name=&quot;Alekhine&#39;s defence&quot;, @eco_code=&quot;B02&quot;, @moves=[:e4, :Nf6]&gt;,
146
+ </span><span class='embdoc'> [ 1] #&lt;Opening:0x007f8209de8950 @name=&quot;Alekhine&#39;s defence, Scandinavian variation&quot;, @eco_code=&quot;B02&quot;, @moves=[:e4, :Nf6, :Nc3, :d5]&gt;,
147
+ </span><span class='embdoc'> [ 2] #&lt;Opening:0x007f8209de87e8 @name=&quot;Alekhine&#39;s defence, Spielmann variation&quot;, @eco_code=&quot;B02&quot;, @moves=[:e4, :Nf6, :Nc3, :d5, :e5, :Nfd7, :e6]&gt;,
148
+ </span><span class='embdoc'> ...
149
+ </span><span class='embdoc'>]
150
+ </span><span class='embdoc_end'>=end
151
+ </span></code></pre>
152
+
153
+ <h4>.get_all</h4>
154
+
155
+ <p>Get all existing openings as an array</p>
156
+
157
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
158
+ <span class='id identifier rubyid_all_openings'>all_openings</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_get_all'>get_all</span>
159
+ <span class='embdoc_beg'>=begin
160
+ </span><span class='embdoc'>[
161
+ </span><span class='embdoc'> [0] #&lt;Opening:0x007f8209dd4b30 @name=&quot;Polish (Sokolsky) opening&quot;, @eco_code=&quot;A00&quot;, @moves=[:b4]&gt;,
162
+ </span><span class='embdoc'> [1] #&lt;Opening:0x007f8209dd4a90 @name=&quot;Polish, Tuebingen variation&quot;, @eco_code=&quot;A00&quot;, @moves=[:b4, :Nh6]&gt;,
163
+ </span><span class='embdoc'> [2] #&lt;Opening:0x007f8209dd49c8 @name=&quot;Polish, Outflank variation&quot;, @eco_code=&quot;A00&quot;, @moves=[:b4, :c6]&gt;,
164
+ </span><span class='embdoc'> ...
165
+ </span><span class='embdoc'>]
166
+ </span><span class='embdoc_end'>=end
167
+ </span></code></pre>
168
+
169
+ <h4>.that_start_with</h4>
170
+
171
+ <p>Get all possible openings that start with determined moves</p>
172
+
173
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
174
+ <span class='id identifier rubyid_e4_e5_openings'>e4_e5_openings</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_that_start_with'>that_start_with</span> <span class='lbracket'>[</span><span class='symbol'>:e4</span><span class='comma'>,</span> <span class='symbol'>:e5</span><span class='rbracket'>]</span>
175
+
176
+ <span class='embdoc_beg'>=begin
177
+ </span><span class='embdoc'>[
178
+ </span><span class='embdoc'> [0] #&lt;Opening:0x007ff69c858258 @name=&quot;King&#39;s pawn game&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5]&gt;,
179
+ </span><span class='embdoc'> [1] #&lt;Opening:0x007ff69c858190 @name=&quot;KP, Indian opening&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5, :d3]&gt;,
180
+ </span><span class='embdoc'> [2] #&lt;Opening:0x007ff69c8580a0 @name=&quot;KP, Mengarini&#39;s opening&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5, :a3]&gt;,
181
+ </span><span class='embdoc'> [3] #&lt;Opening:0x007ff69a1a3dd8 @name=&quot;KP, King&#39;s head opening&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5, :f3]&gt;,
182
+ </span><span class='embdoc'> [4] #&lt;Opening:0x007ff69a1a3248 @name=&quot;KP, Patzer opening&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5, :Qh5]&gt;
183
+ </span><span class='embdoc'> ...
184
+ </span><span class='embdoc'>]
185
+ </span><span class='embdoc_end'>=end
186
+ </span></code></pre>
187
+
188
+ <h4>.from_fen</h4>
189
+
190
+ <p>Get opening from FEN string</p>
191
+
192
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_opening_from_fen'>opening_from_fen</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_from_fen'>from_fen</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq e6 0 2</span><span class='tstring_end'>&#39;</span></span>
193
+ <span class='comment'>#=&gt; #&lt;Opening:0x007ff69c858258 @name=&quot;King&#39;s pawn game&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5]&gt;
194
+ </span></code></pre>
195
+
196
+ <p>When you have a opening you can invoke these methods on it:</p>
197
+
198
+ <h4>.to_pgn</h4>
199
+
200
+ <p>Get PGN string from an opening</p>
201
+
202
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_opening'>opening</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_from_moves'>from_moves</span> <span class='lbracket'>[</span><span class='symbol'>:e4</span><span class='comma'>,</span> <span class='symbol'>:e5</span><span class='comma'>,</span> <span class='symbol'>:Nf3</span><span class='comma'>,</span> <span class='symbol'>:Nc6</span><span class='comma'>,</span> <span class='symbol'>:Bb5</span><span class='comma'>,</span> <span class='symbol'>:a6</span><span class='comma'>,</span> <span class='symbol'>:Bxc6</span><span class='rbracket'>]</span>
203
+ <span class='comment'>#=&gt; #&lt;Opening:0x007f820961bf60 @name=&quot;Ruy Lopez, exchange variation&quot;, @eco_code=&quot;C68&quot;, @moves=[:e4, :e5, :Nf3, :Nc6, :Bb5, :a6, :Bxc6]&gt;
204
+ </span><span class='id identifier rubyid_opening'>opening</span><span class='period'>.</span><span class='id identifier rubyid_to_pgn'>to_pgn</span>
205
+ <span class='comment'>#=&gt; &quot;1.e4 e5 2.Nf3 Nc6 3.Bb5 a6 4.Bxc6&quot;
206
+ </span></code></pre>
207
+
208
+ <h4>.to_fen</h4>
209
+
210
+ <p>Get FEN string of the opening</p>
211
+
212
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_opening'>opening</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_from_moves'>from_moves</span> <span class='lbracket'>[</span><span class='symbol'>:e4</span><span class='comma'>,</span> <span class='symbol'>:e5</span><span class='rbracket'>]</span>
213
+ <span class='comment'>#=&gt; #&lt;Opening:0x007ff69c858258 @name=&quot;King&#39;s pawn game&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5]&gt;
214
+ </span><span class='id identifier rubyid_opening'>opening</span><span class='period'>.</span><span class='id identifier rubyid_to_fen'>to_fen</span>
215
+ <span class='comment'>#=&gt; &#39;rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq e6 0 2&#39;
216
+ </span></code></pre>
217
+
218
+ <h2>Development</h2>
219
+
220
+ <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code> to create a git tag for the version, push git commits and tags, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
221
+
222
+ <h2>Contributing</h2>
223
+
224
+ <ol>
225
+ <li>Fork it ( <a href="https://github.com/simaoneves/chess_openings/fork">https://github.com/simaoneves/chess_openings/fork</a> )</li>
226
+ <li>Create your feature branch (<code>git checkout -b my-new-feature</code>)</li>
227
+ <li>Commit your changes (<code>git commit -am &#39;Add some feature&#39;</code>)</li>
228
+ <li>Push to the branch (<code>git push origin my-new-feature</code>)</li>
229
+ <li>Create a new Pull Request</li>
230
+ </ol>
231
+ </div></div>
232
+
233
+ <div id="footer">
234
+ Generated on Thu Jan 12 10:12:16 2017 by
235
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
236
+ 0.9.7 (ruby-2.2.0).
237
+ </div>
238
+
239
+ </div>
240
+ </body>
241
+ </html>
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <title>File List</title>
19
+ <base id="base_target" target="_parent" />
20
+ </head>
21
+ <body>
22
+ <div id="content">
23
+ <div class="fixed_header">
24
+ <h1 id="full_list_header">File List</h1>
25
+ <div id="full_list_nav">
26
+
27
+ <span><a target="_self" href="class_list.html">
28
+ Classes
29
+ </a></span>
30
+
31
+ <span><a target="_self" href="method_list.html">
32
+ Methods
33
+ </a></span>
34
+
35
+ <span><a target="_self" href="file_list.html">
36
+ Files
37
+ </a></span>
38
+
39
+ </div>
40
+
41
+ <div id="search">Search: <input type="text" /></div>
42
+ </div>
43
+
44
+ <ul id="full_list" class="file">
45
+
46
+
47
+ <li id="object_README" class="odd">
48
+ <div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
49
+ </li>
50
+
51
+
52
+
53
+ </ul>
54
+ </div>
55
+ </body>
56
+ </html>
data/doc/frames.html ADDED
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Documentation by YARD 0.9.7</title>
6
+ </head>
7
+ <script type="text/javascript" charset="utf-8">
8
+ var match = unescape(window.location.hash).match(/^#!(.+)/);
9
+ var name = match ? match[1] : 'index.html';
10
+ name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
11
+ window.top.location = name;
12
+ </script>
13
+ <noscript>
14
+ <h1>Oops!</h1>
15
+ <h2>YARD requires JavaScript!</h2>
16
+ </noscript>
17
+ </html>
data/doc/index.html ADDED
@@ -0,0 +1,241 @@
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
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.7
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "README";
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</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><h1>Chess Openings</h1>
61
+
62
+ <p>Ruby gem that where you can manipulate, search for and get information from chess openings.</p>
63
+
64
+ <h2>TODOS:</h2>
65
+
66
+ <ul>
67
+ <li>Write documentation</li>
68
+ </ul>
69
+
70
+ <h2>Features:</h2>
71
+
72
+ <ul>
73
+ <li>Get opening from PGN file</li>
74
+ <li>Get opening from PGN string</li>
75
+ <li>Get opening from array with moves</li>
76
+ <li>Get opening from FEN</li>
77
+ <li>Search opening by name</li>
78
+ <li>Get all openings</li>
79
+ <li>Get all openings that start with some determined moves</li>
80
+ <li>Get PGN string from an opening</li>
81
+ <li>Get FEN from an opening</li>
82
+ </ul>
83
+
84
+ <h2>Installation</h2>
85
+
86
+ <p>Add this line to your application&#39;s Gemfile:</p>
87
+
88
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>chess_openings</span><span class='tstring_end'>&#39;</span></span>
89
+ </code></pre>
90
+
91
+ <p>And then execute:</p>
92
+
93
+ <pre class="code ruby"><code class="ruby">$ bundle
94
+ </code></pre>
95
+
96
+ <p>Or install it yourself as:</p>
97
+
98
+ <pre class="code ruby"><code class="ruby">$ gem install chess_openings
99
+ </code></pre>
100
+
101
+ <h2>Usage</h2>
102
+
103
+ <p>First things first, you need to create a new ChessOpenings object:</p>
104
+
105
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
106
+ </code></pre>
107
+
108
+ <p>From here you can use several functions:</p>
109
+
110
+ <h4>.from_pgn</h4>
111
+
112
+ <p>Get opening from PGN file</p>
113
+
114
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
115
+ <span class='id identifier rubyid_opening'>opening</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_from_pgn'>from_pgn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>path_to/pgn_game.pgn</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
116
+ <span class='comment'>#=&gt; #&lt;Opening:0x007fda6237b510 @name=&quot;English, Sicilian reversed&quot;, @eco_code=&quot;A25&quot;, @moves=[:c4, :e5, :Nc3, :Nc6]&gt;
117
+ </span></code></pre>
118
+
119
+ <h4>.from_string</h4>
120
+
121
+ <p>Get opening from a string, formated like a PGN file</p>
122
+
123
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
124
+ <span class='id identifier rubyid_opening'>opening</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_from_string'>from_string</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>1.e4 e5 2.Nf3 Nc6 3.Bb5 a6 4.Bxc6</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
125
+ <span class='comment'>#=&gt; #&lt;Opening:0x007f820961bf60 @name=&quot;Ruy Lopez, exchange variation&quot;, @eco_code=&quot;C68&quot;, @moves=[:e4, :e5, :Nf3, :Nc6, :Bb5, :a6, :Bxc6]&gt;
126
+ </span></code></pre>
127
+
128
+ <h4>.from_moves</h4>
129
+
130
+ <p>Get opening from an array with moves (as symbols or strings)</p>
131
+
132
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
133
+ <span class='id identifier rubyid_opening'>opening</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_from_moves'>from_moves</span> <span class='lbracket'>[</span><span class='symbol'>:e4</span><span class='comma'>,</span> <span class='symbol'>:c6</span><span class='comma'>,</span> <span class='symbol'>:d4</span><span class='comma'>,</span> <span class='symbol'>:d5</span><span class='rbracket'>]</span>
134
+ <span class='comment'>#=&gt; #&lt;Opening:0x007f8209d9c910 @name=&quot;Caro-Kann defence&quot;, @eco_code=&quot;B12&quot;, @moves=[:e4, :c6, :d4, :d5]&gt;
135
+ </span></code></pre>
136
+
137
+ <h4>.with_name</h4>
138
+
139
+ <p>Search openings by name</p>
140
+
141
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
142
+ <span class='id identifier rubyid_openings'>openings</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_with_name'>with_name</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>alekhine defence</span><span class='tstring_end'>&quot;</span></span>
143
+ <span class='embdoc_beg'>=begin
144
+ </span><span class='embdoc'>[
145
+ </span><span class='embdoc'> [ 0] #&lt;Opening:0x007f8209de8a18 @name=&quot;Alekhine&#39;s defence&quot;, @eco_code=&quot;B02&quot;, @moves=[:e4, :Nf6]&gt;,
146
+ </span><span class='embdoc'> [ 1] #&lt;Opening:0x007f8209de8950 @name=&quot;Alekhine&#39;s defence, Scandinavian variation&quot;, @eco_code=&quot;B02&quot;, @moves=[:e4, :Nf6, :Nc3, :d5]&gt;,
147
+ </span><span class='embdoc'> [ 2] #&lt;Opening:0x007f8209de87e8 @name=&quot;Alekhine&#39;s defence, Spielmann variation&quot;, @eco_code=&quot;B02&quot;, @moves=[:e4, :Nf6, :Nc3, :d5, :e5, :Nfd7, :e6]&gt;,
148
+ </span><span class='embdoc'> ...
149
+ </span><span class='embdoc'>]
150
+ </span><span class='embdoc_end'>=end
151
+ </span></code></pre>
152
+
153
+ <h4>.get_all</h4>
154
+
155
+ <p>Get all existing openings as an array</p>
156
+
157
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
158
+ <span class='id identifier rubyid_all_openings'>all_openings</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_get_all'>get_all</span>
159
+ <span class='embdoc_beg'>=begin
160
+ </span><span class='embdoc'>[
161
+ </span><span class='embdoc'> [0] #&lt;Opening:0x007f8209dd4b30 @name=&quot;Polish (Sokolsky) opening&quot;, @eco_code=&quot;A00&quot;, @moves=[:b4]&gt;,
162
+ </span><span class='embdoc'> [1] #&lt;Opening:0x007f8209dd4a90 @name=&quot;Polish, Tuebingen variation&quot;, @eco_code=&quot;A00&quot;, @moves=[:b4, :Nh6]&gt;,
163
+ </span><span class='embdoc'> [2] #&lt;Opening:0x007f8209dd49c8 @name=&quot;Polish, Outflank variation&quot;, @eco_code=&quot;A00&quot;, @moves=[:b4, :c6]&gt;,
164
+ </span><span class='embdoc'> ...
165
+ </span><span class='embdoc'>]
166
+ </span><span class='embdoc_end'>=end
167
+ </span></code></pre>
168
+
169
+ <h4>.that_start_with</h4>
170
+
171
+ <p>Get all possible openings that start with determined moves</p>
172
+
173
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_chess_openings'>chess_openings</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="ChessOpenings.html" title="ChessOpenings (class)">ChessOpenings</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ChessOpenings.html#initialize-instance_method" title="ChessOpenings#initialize (method)">new</a></span></span>
174
+ <span class='id identifier rubyid_e4_e5_openings'>e4_e5_openings</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_that_start_with'>that_start_with</span> <span class='lbracket'>[</span><span class='symbol'>:e4</span><span class='comma'>,</span> <span class='symbol'>:e5</span><span class='rbracket'>]</span>
175
+
176
+ <span class='embdoc_beg'>=begin
177
+ </span><span class='embdoc'>[
178
+ </span><span class='embdoc'> [0] #&lt;Opening:0x007ff69c858258 @name=&quot;King&#39;s pawn game&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5]&gt;,
179
+ </span><span class='embdoc'> [1] #&lt;Opening:0x007ff69c858190 @name=&quot;KP, Indian opening&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5, :d3]&gt;,
180
+ </span><span class='embdoc'> [2] #&lt;Opening:0x007ff69c8580a0 @name=&quot;KP, Mengarini&#39;s opening&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5, :a3]&gt;,
181
+ </span><span class='embdoc'> [3] #&lt;Opening:0x007ff69a1a3dd8 @name=&quot;KP, King&#39;s head opening&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5, :f3]&gt;,
182
+ </span><span class='embdoc'> [4] #&lt;Opening:0x007ff69a1a3248 @name=&quot;KP, Patzer opening&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5, :Qh5]&gt;
183
+ </span><span class='embdoc'> ...
184
+ </span><span class='embdoc'>]
185
+ </span><span class='embdoc_end'>=end
186
+ </span></code></pre>
187
+
188
+ <h4>.from_fen</h4>
189
+
190
+ <p>Get opening from FEN string</p>
191
+
192
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_opening_from_fen'>opening_from_fen</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_from_fen'>from_fen</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq e6 0 2</span><span class='tstring_end'>&#39;</span></span>
193
+ <span class='comment'>#=&gt; #&lt;Opening:0x007ff69c858258 @name=&quot;King&#39;s pawn game&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5]&gt;
194
+ </span></code></pre>
195
+
196
+ <p>When you have a opening you can invoke these methods on it:</p>
197
+
198
+ <h4>.to_pgn</h4>
199
+
200
+ <p>Get PGN string from an opening</p>
201
+
202
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_opening'>opening</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_from_moves'>from_moves</span> <span class='lbracket'>[</span><span class='symbol'>:e4</span><span class='comma'>,</span> <span class='symbol'>:e5</span><span class='comma'>,</span> <span class='symbol'>:Nf3</span><span class='comma'>,</span> <span class='symbol'>:Nc6</span><span class='comma'>,</span> <span class='symbol'>:Bb5</span><span class='comma'>,</span> <span class='symbol'>:a6</span><span class='comma'>,</span> <span class='symbol'>:Bxc6</span><span class='rbracket'>]</span>
203
+ <span class='comment'>#=&gt; #&lt;Opening:0x007f820961bf60 @name=&quot;Ruy Lopez, exchange variation&quot;, @eco_code=&quot;C68&quot;, @moves=[:e4, :e5, :Nf3, :Nc6, :Bb5, :a6, :Bxc6]&gt;
204
+ </span><span class='id identifier rubyid_opening'>opening</span><span class='period'>.</span><span class='id identifier rubyid_to_pgn'>to_pgn</span>
205
+ <span class='comment'>#=&gt; &quot;1.e4 e5 2.Nf3 Nc6 3.Bb5 a6 4.Bxc6&quot;
206
+ </span></code></pre>
207
+
208
+ <h4>.to_fen</h4>
209
+
210
+ <p>Get FEN string of the opening</p>
211
+
212
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_opening'>opening</span> <span class='op'>=</span> <span class='id identifier rubyid_chess_openings'>chess_openings</span><span class='period'>.</span><span class='id identifier rubyid_from_moves'>from_moves</span> <span class='lbracket'>[</span><span class='symbol'>:e4</span><span class='comma'>,</span> <span class='symbol'>:e5</span><span class='rbracket'>]</span>
213
+ <span class='comment'>#=&gt; #&lt;Opening:0x007ff69c858258 @name=&quot;King&#39;s pawn game&quot;, @eco_code=&quot;C20&quot;, @moves=[:e4, :e5]&gt;
214
+ </span><span class='id identifier rubyid_opening'>opening</span><span class='period'>.</span><span class='id identifier rubyid_to_fen'>to_fen</span>
215
+ <span class='comment'>#=&gt; &#39;rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq e6 0 2&#39;
216
+ </span></code></pre>
217
+
218
+ <h2>Development</h2>
219
+
220
+ <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code> to create a git tag for the version, push git commits and tags, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
221
+
222
+ <h2>Contributing</h2>
223
+
224
+ <ol>
225
+ <li>Fork it ( <a href="https://github.com/simaoneves/chess_openings/fork">https://github.com/simaoneves/chess_openings/fork</a> )</li>
226
+ <li>Create your feature branch (<code>git checkout -b my-new-feature</code>)</li>
227
+ <li>Commit your changes (<code>git commit -am &#39;Add some feature&#39;</code>)</li>
228
+ <li>Push to the branch (<code>git push origin my-new-feature</code>)</li>
229
+ <li>Create a new Pull Request</li>
230
+ </ol>
231
+ </div></div>
232
+
233
+ <div id="footer">
234
+ Generated on Thu Jan 12 10:12:16 2017 by
235
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
236
+ 0.9.7 (ruby-2.2.0).
237
+ </div>
238
+
239
+ </div>
240
+ </body>
241
+ </html>