]> git.r.bdr.sh - rbdr/lyricli.rb/blame - doc/Lyricli/LyricsEngine.html
One more note to the readme
[rbdr/lyricli.rb] / doc / Lyricli / LyricsEngine.html
CommitLineData
823e558b
BB
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6<title>
7 Class: Lyricli::LyricsEngine
8
34d0bf15 9 &mdash; Documentation by YARD 0.8.2.1
823e558b
BB
10
11</title>
12
13 <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
15 <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
17<script type="text/javascript" charset="utf-8">
18 hasFrames = window.top.frames.main ? true : false;
19 relpath = '../';
20 framesUrl = "../frames.html#!" + escape(window.location.href);
21</script>
22
23
24 <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
25
26 <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
27
28
29 </head>
30 <body>
31 <div id="header">
32 <div id="menu">
33
34 <a href="../_index.html">Index (L)</a> &raquo;
35 <span class='title'><span class='object_link'><a href="../Lyricli.html" title="Lyricli (module)">Lyricli</a></span></span>
36 &raquo;
37 <span class="title">LyricsEngine</span>
38
39
40 <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41</div>
42
43 <div id="search">
44
45 <a class="full_list_link" id="class_list_link"
46 href="../class_list.html">
47 Class List
48 </a>
49
50 <a class="full_list_link" id="method_list_link"
51 href="../method_list.html">
52 Method List
53 </a>
54
55 <a class="full_list_link" id="file_list_link"
56 href="../file_list.html">
57 File List
58 </a>
59
60</div>
61 <div class="clear"></div>
62 </div>
63
64 <iframe id="search_frame"></iframe>
65
66 <div id="content"><h1>Class: Lyricli::LyricsEngine
67
68
69
70</h1>
71
72<dl class="box">
73
74 <dt class="r1">Inherits:</dt>
75 <dd class="r1">
76 <span class="inheritName">Object</span>
77
78 <ul class="fullTree">
79 <li>Object</li>
80
81 <li class="next">Lyricli::LyricsEngine</li>
82
83 </ul>
84 <a href="#" class="inheritanceTree">show all</a>
85
86 </dd>
87
88
89
90
91
92
93 <dt class="r2">Includes:</dt>
94 <dd class="r2"><span class='object_link'><a href="Util.html" title="Lyricli::Util (module)">Util</a></span></dd>
95
96
97
98
99
100 <dt class="r1 last">Defined in:</dt>
101 <dd class="r1 last">lib/lyricli/lyrics_engine.rb</dd>
102
103</dl>
104<div class="clear"></div>
105
f2ec7254
BB
106<h2>Overview</h2><div class="docstring">
107 <div class="discussion">
108 <p>
109This class gets the lyrics according to a given artist and song name.
110</p>
823e558b
BB
111
112
f2ec7254
BB
113 </div>
114</div>
115<div class="tags">
116
117
118</div>
119
823e558b
BB
120
121
122
123
124
125
126 <h2>
127 Instance Method Summary
128 <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
129 </h2>
130
131 <ul class="summary">
132
133 <li class="public ">
134 <span class="summary_signature">
135
f2ec7254 136 <a href="#get_lyrics-instance_method" title="#get_lyrics (instance method)">- (String) <strong>get_lyrics</strong> </a>
823e558b
BB
137
138
139
140 </span>
141
142
143
144
145
146
147
148
149
f2ec7254
BB
150 <span class="summary_desc"><div class='inline'><p>
151Asks Lyrics Wiki for the lyrics, also cleans up the output a little.
152</p>
153</div></span>
823e558b
BB
154
155</li>
156
157
158 <li class="public ">
159 <span class="summary_signature">
160
161 <a href="#initialize-instance_method" title="#initialize (instance method)">- (LyricsEngine) <strong>initialize</strong>(artist, song) </a>
162
163
164
165 </span>
166
167
168 <span class="note title constructor">constructor</span>
169
170
171
172
173
174
175
176
177 <span class="summary_desc"><div class='inline'><p>
f2ec7254 178Starts a new instance of LyricsEngine.
823e558b
BB
179</p>
180</div></span>
181
182</li>
183
184
185 </ul>
186
187
188
189
190
191
192
193
194
195
196
197 <h3 class="inherited">Methods included from <span class='object_link'><a href="Util.html" title="Lyricli::Util (module)">Util</a></span></h3>
198 <p class="inherited"><span class='object_link'><a href="Util.html#camelize-instance_method" title="Lyricli::Util#camelize (method)">#camelize</a></span>, <span class='object_link'><a href="Util.html#parse_class-instance_method" title="Lyricli::Util#parse_class (method)">#parse_class</a></span>, <span class='object_link'><a href="Util.html#sanitize_param-instance_method" title="Lyricli::Util#sanitize_param (method)">#sanitize_param</a></span></p>
199<div id="constructor_details" class="method_details_list">
200 <h2>Constructor Details</h2>
201
202 <div class="method_details first">
203 <h3 class="signature first" id="initialize-instance_method">
204
205 - (<tt><span class='object_link'><a href="" title="Lyricli::LyricsEngine (class)">LyricsEngine</a></span></tt>) <strong>initialize</strong>(artist, song)
206
207
208
209
210
211</h3><div class="docstring">
212 <div class="discussion">
213 <p>
f2ec7254 214Starts a new instance of LyricsEngine
823e558b
BB
215</p>
216
217
218 </div>
219</div>
220<div class="tags">
f2ec7254
BB
221 <p class="tag_title">Parameters:</p>
222<ul class="param">
223
224 <li>
225
226 <span class='name'>artist</span>
227
228
229 <span class='type'>(<tt>String</tt>)</span>
230
231
232
233 &mdash;
234 <div class='inline'><p>
235the artist
236</p>
237</div>
238
239 </li>
240
241 <li>
242
243 <span class='name'>song</span>
244
245
246 <span class='type'>(<tt>String</tt>)</span>
247
248
249
250 &mdash;
251 <div class='inline'><p>
252the song to look for
253</p>
254</div>
255
256 </li>
823e558b 257
f2ec7254
BB
258</ul>
259
823e558b
BB
260
261</div><table class="source_code">
262 <tr>
263 <td>
264 <pre class="lines">
265
266
f2ec7254
BB
26712
26813
26914</pre>
823e558b
BB
270 </td>
271 <td>
f2ec7254 272 <pre class="code"><span class="info file"># File 'lib/lyricli/lyrics_engine.rb', line 12</span>
823e558b
BB
273
274<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_artist'>artist</span><span class='comma'>,</span> <span class='id identifier rubyid_song'>song</span><span class='rparen'>)</span>
275 <span class='ivar'>@provider</span> <span class='op'>=</span> <span class='const'>URI</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>http://lyrics.wikia.com/api.php?artist=</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sanitize_param'>sanitize_param</span> <span class='id identifier rubyid_artist'>artist</span><span class='rbrace'>}</span><span class='tstring_content'>&amp;song=</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sanitize_param'>sanitize_param</span> <span class='id identifier rubyid_song'>song</span><span class='rbrace'>}</span><span class='tstring_content'>&amp;fmt=realjson</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
276<span class='kw'>end</span></pre>
277 </td>
278 </tr>
279</table>
280</div>
281
282</div>
283
284
285 <div id="instance_method_details" class="method_details_list">
286 <h2>Instance Method Details</h2>
287
288
289 <div class="method_details first">
290 <h3 class="signature first" id="get_lyrics-instance_method">
291
f2ec7254 292 - (<tt>String</tt>) <strong>get_lyrics</strong>
823e558b
BB
293
294
295
296
297
f2ec7254
BB
298</h3><div class="docstring">
299 <div class="discussion">
300 <p>
301Asks Lyrics Wiki for the lyrics, also cleans up the output a little.
302</p>
303
304
305 </div>
306</div>
307<div class="tags">
308
309<p class="tag_title">Returns:</p>
310<ul class="return">
311
312 <li>
313
314
315 <span class='type'>(<tt>String</tt>)</span>
316
317
318
319 &mdash;
320 <div class='inline'><p>
321the lyrics
322</p>
323</div>
324
325 </li>
326
327</ul>
328
329</div><table class="source_code">
823e558b
BB
330 <tr>
331 <td>
332 <pre class="lines">
333
334
823e558b
BB
33519
33620
33721
33822
33923
34024
34125
34226
34327
34428
34529
f2ec7254
BB
34630
34731
34832
34933
35034
35135
35236
35337
35438
35539</pre>
823e558b
BB
356 </td>
357 <td>
f2ec7254 358 <pre class="code"><span class="info file"># File 'lib/lyricli/lyrics_engine.rb', line 19</span>
823e558b
BB
359
360<span class='kw'>def</span> <span class='id identifier rubyid_get_lyrics'>get_lyrics</span>
361 <span class='kw'>begin</span>
362 <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='const'>Net</span><span class='op'>::</span><span class='const'>HTTP</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='ivar'>@provider</span><span class='rparen'>)</span>
363 <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='const'>MultiJson</span><span class='period'>.</span><span class='id identifier rubyid_decode'>decode</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
364
365 <span class='id identifier rubyid_doc'>doc</span> <span class='op'>=</span> <span class='const'>Nokogiri</span><span class='op'>::</span><span class='const'>HTML</span><span class='lparen'>(</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>url</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span>
366 <span class='id identifier rubyid_node'>node</span> <span class='op'>=</span> <span class='id identifier rubyid_doc'>doc</span><span class='period'>.</span><span class='id identifier rubyid_search'>search</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>.lyricbox</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
367 <span class='kw'>rescue</span>
278e6d0a 368 <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>LyricsNotFoundError</span>
823e558b
BB
369 <span class='kw'>end</span>
370
371 <span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_search'>search</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>.rtMatcher</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</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_n'>n</span><span class='op'>|</span>
372 <span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span>
373 <span class='kw'>end</span>
374
375 <span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_search'>search</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>br</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</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_br'>br</span><span class='op'>|</span>
376 <span class='id identifier rubyid_br'>br</span><span class='period'>.</span><span class='id identifier rubyid_replace'>replace</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span>
377 <span class='kw'>end</span>
378
379 <span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_inner_text'>inner_text</span>
380<span class='kw'>end</span></pre>
381 </td>
382 </tr>
383</table>
384</div>
385
386 </div>
387
388</div>
389
390 <div id="footer">
278e6d0a 391 Generated on Sat Oct 6 03:20:24 2012 by
823e558b 392 <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
34d0bf15 393 0.8.2.1 (ruby-1.9.2).
823e558b
BB
394</div>
395
396 </body>
397</html>