]> git.r.bdr.sh - rbdr/lyricli.rb/blob - doc/Lyricli/Lyricli.html
Merge pull request #2 from orlando/master
[rbdr/lyricli.rb] / doc / Lyricli / Lyricli.html
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::Lyricli
8
9 &mdash; Documentation by YARD 0.8.2.1
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">Lyricli</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::Lyricli
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::Lyricli</li>
82
83 </ul>
84 <a href="#" class="inheritanceTree">show all</a>
85
86 </dd>
87
88
89
90
91
92
93
94
95
96 <dt class="r2 last">Defined in:</dt>
97 <dd class="r2 last">lib/lyricli/lyricli.rb</dd>
98
99 </dl>
100 <div class="clear"></div>
101
102 <h2>Overview</h2><div class="docstring">
103 <div class="discussion">
104 <p>
105 This class has the basic logic for extracting the lyrics and controlling
106 the application
107 </p>
108
109
110 </div>
111 </div>
112 <div class="tags">
113
114
115 </div>
116
117
118
119
120
121
122
123 <h2>
124 Instance Method Summary
125 <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
126 </h2>
127
128 <ul class="summary">
129
130 <li class="public ">
131 <span class="summary_signature">
132
133 <a href="#check_params-instance_method" title="#check_params (instance method)">- (Object) <strong>check_params</strong> </a>
134
135
136
137 </span>
138
139
140
141
142
143
144
145
146
147 <span class="summary_desc"><div class='inline'><p>
148 Exits with error when there is an empty field from the current track.
149 </p>
150 </div></span>
151
152 </li>
153
154
155 <li class="public ">
156 <span class="summary_signature">
157
158 <a href="#exit_with_error-instance_method" title="#exit_with_error (instance method)">- (Object) <strong>exit_with_error</strong> </a>
159
160
161
162 </span>
163
164
165
166
167
168
169
170
171
172 <span class="summary_desc"><div class='inline'><p>
173 Raises an InvalidLyricsError which means we did not get any valid
174 artist/song from any of the sources.
175 </p>
176 </div></span>
177
178 </li>
179
180
181 <li class="public ">
182 <span class="summary_signature">
183
184 <a href="#get_lyrics-instance_method" title="#get_lyrics (instance method)">- (String) <strong>get_lyrics</strong> </a>
185
186
187
188 </span>
189
190
191
192
193
194
195
196
197
198 <span class="summary_desc"><div class='inline'><p>
199 Extracts the current track, validates it and requests the lyrics from our
200 LyricsEngine.
201 </p>
202 </div></span>
203
204 </li>
205
206
207 <li class="public ">
208 <span class="summary_signature">
209
210 <a href="#initialize-instance_method" title="#initialize (instance method)">- (Lyricli) <strong>initialize</strong> </a>
211
212
213
214 </span>
215
216
217 <span class="note title constructor">constructor</span>
218
219
220
221
222
223
224
225
226 <span class="summary_desc"><div class='inline'><p>
227 Constructor, initializes `@source_manager`.
228 </p>
229 </div></span>
230
231 </li>
232
233
234 <li class="public ">
235 <span class="summary_signature">
236
237 <a href="#set_current_track-instance_method" title="#set_current_track (instance method)">- (Object) <strong>set_current_track</strong> </a>
238
239
240
241 </span>
242
243
244
245
246
247
248
249
250
251 <span class="summary_desc"><div class='inline'><p>
252 Set the `@current_track` instance variable by asking the SourceManager for
253 its current track.
254 </p>
255 </div></span>
256
257 </li>
258
259
260 </ul>
261
262
263 <div id="constructor_details" class="method_details_list">
264 <h2>Constructor Details</h2>
265
266 <div class="method_details first">
267 <h3 class="signature first" id="initialize-instance_method">
268
269 - (<tt><span class='object_link'><a href="" title="Lyricli::Lyricli (class)">Lyricli</a></span></tt>) <strong>initialize</strong>
270
271
272
273
274
275 </h3><div class="docstring">
276 <div class="discussion">
277 <p>
278 Constructor, initializes `@source_manager`
279 </p>
280
281
282 </div>
283 </div>
284 <div class="tags">
285
286
287 </div><table class="source_code">
288 <tr>
289 <td>
290 <pre class="lines">
291
292
293 8
294 9
295 10</pre>
296 </td>
297 <td>
298 <pre class="code"><span class="info file"># File 'lib/lyricli/lyricli.rb', line 8</span>
299
300 <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
301 <span class='ivar'>@source_manager</span> <span class='op'>=</span> <span class='const'>SourceManager</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
302 <span class='kw'>end</span></pre>
303 </td>
304 </tr>
305 </table>
306 </div>
307
308 </div>
309
310
311 <div id="instance_method_details" class="method_details_list">
312 <h2>Instance Method Details</h2>
313
314
315 <div class="method_details first">
316 <h3 class="signature first" id="check_params-instance_method">
317
318 - (<tt>Object</tt>) <strong>check_params</strong>
319
320
321
322
323
324 </h3><div class="docstring">
325 <div class="discussion">
326 <p>
327 Exits with error when there is an empty field from the current track.
328 </p>
329
330
331 </div>
332 </div>
333 <div class="tags">
334
335
336 </div><table class="source_code">
337 <tr>
338 <td>
339 <pre class="lines">
340
341
342 49
343 50
344 51
345 52
346 53</pre>
347 </td>
348 <td>
349 <pre class="code"><span class="info file"># File 'lib/lyricli/lyricli.rb', line 49</span>
350
351 <span class='kw'>def</span> <span class='id identifier rubyid_check_params'>check_params</span>
352 <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_exit_with_error'>exit_with_error</span> <span class='kw'>unless</span> <span class='ivar'>@current_track</span>
353 <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_exit_with_error'>exit_with_error</span> <span class='kw'>if</span> <span class='ivar'>@current_track</span><span class='lbracket'>[</span><span class='symbol'>:artist</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='kw'>or</span> <span class='ivar'>@current_track</span><span class='lbracket'>[</span><span class='symbol'>:artist</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
354 <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_exit_with_error'>exit_with_error</span> <span class='kw'>if</span> <span class='ivar'>@current_track</span><span class='lbracket'>[</span><span class='symbol'>:song</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='kw'>or</span> <span class='ivar'>@current_track</span><span class='lbracket'>[</span><span class='symbol'>:song</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
355 <span class='kw'>end</span></pre>
356 </td>
357 </tr>
358 </table>
359 </div>
360
361 <div class="method_details ">
362 <h3 class="signature " id="exit_with_error-instance_method">
363
364 - (<tt>Object</tt>) <strong>exit_with_error</strong>
365
366
367
368
369
370 </h3><div class="docstring">
371 <div class="discussion">
372 <p>
373 Raises an InvalidLyricsError which means we did not get any valid
374 artist/song from any of the sources
375 </p>
376
377
378 </div>
379 </div>
380 <div class="tags">
381
382 <p class="tag_title">Raises:</p>
383 <ul class="raise">
384
385 <li>
386
387
388 <span class='type'>(<tt><span class='object_link'><a href="Exceptions/InvalidLyricsError.html" title="Lyricli::Exceptions::InvalidLyricsError (class)">Lyricli::Exceptions::InvalidLyricsError</a></span></tt>)</span>
389
390
391
392 &mdash;
393 <div class='inline'><p>
394 because we found nothing
395 </p>
396 </div>
397
398 </li>
399
400 </ul>
401
402 </div><table class="source_code">
403 <tr>
404 <td>
405 <pre class="lines">
406
407
408 16
409 17
410 18</pre>
411 </td>
412 <td>
413 <pre class="code"><span class="info file"># File 'lib/lyricli/lyricli.rb', line 16</span>
414
415 <span class='kw'>def</span> <span class='id identifier rubyid_exit_with_error'>exit_with_error</span>
416 <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>InvalidLyricsError</span>
417 <span class='kw'>end</span></pre>
418 </td>
419 </tr>
420 </table>
421 </div>
422
423 <div class="method_details ">
424 <h3 class="signature " id="get_lyrics-instance_method">
425
426 - (<tt>String</tt>) <strong>get_lyrics</strong>
427
428
429
430
431
432 </h3><div class="docstring">
433 <div class="discussion">
434 <p>
435 Extracts the current track, validates it and requests the lyrics from our
436 LyricsEngine
437 </p>
438
439
440 </div>
441 </div>
442 <div class="tags">
443
444 <p class="tag_title">Returns:</p>
445 <ul class="return">
446
447 <li>
448
449
450 <span class='type'>(<tt>String</tt>)</span>
451
452
453
454 &mdash;
455 <div class='inline'><p>
456 the found lyrics, or a string indicating none were found
457 </p>
458 </div>
459
460 </li>
461
462 </ul>
463
464 </div><table class="source_code">
465 <tr>
466 <td>
467 <pre class="lines">
468
469
470 24
471 25
472 26
473 27
474 28
475 29
476 30
477 31
478 32
479 33
480 34
481 35
482 36
483 37
484 38
485 39
486 40</pre>
487 </td>
488 <td>
489 <pre class="code"><span class="info file"># File 'lib/lyricli/lyricli.rb', line 24</span>
490
491 <span class='kw'>def</span> <span class='id identifier rubyid_get_lyrics'>get_lyrics</span>
492
493 <span class='kw'>begin</span>
494 <span class='id identifier rubyid_set_current_track'>set_current_track</span>
495 <span class='id identifier rubyid_check_params'>check_params</span>
496 <span class='kw'>rescue</span> <span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>InvalidLyricsError</span>
497 <span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>No Artist/Song could be found :(</span><span class='tstring_end'>&quot;</span></span>
498 <span class='kw'>end</span>
499
500 <span class='id identifier rubyid_engine'>engine</span> <span class='op'>=</span> <span class='const'>LyricsEngine</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@current_track</span><span class='lbracket'>[</span><span class='symbol'>:artist</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='ivar'>@current_track</span><span class='lbracket'>[</span><span class='symbol'>:song</span><span class='rbracket'>]</span><span class='rparen'>)</span>
501
502 <span class='kw'>begin</span>
503 <span class='kw'>return</span> <span class='id identifier rubyid_engine'>engine</span><span class='period'>.</span><span class='id identifier rubyid_get_lyrics'>get_lyrics</span>
504 <span class='kw'>rescue</span> <span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>LyricsNotFoundError</span>
505 <span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Lyrics not found :(</span><span class='tstring_end'>&quot;</span></span>
506 <span class='kw'>end</span>
507 <span class='kw'>end</span></pre>
508 </td>
509 </tr>
510 </table>
511 </div>
512
513 <div class="method_details ">
514 <h3 class="signature " id="set_current_track-instance_method">
515
516 - (<tt>Object</tt>) <strong>set_current_track</strong>
517
518
519
520
521
522 </h3><div class="docstring">
523 <div class="discussion">
524 <p>
525 Set the `@current_track` instance variable by asking the SourceManager for
526 its current track
527 </p>
528
529
530 </div>
531 </div>
532 <div class="tags">
533
534
535 </div><table class="source_code">
536 <tr>
537 <td>
538 <pre class="lines">
539
540
541 44
542 45
543 46</pre>
544 </td>
545 <td>
546 <pre class="code"><span class="info file"># File 'lib/lyricli/lyricli.rb', line 44</span>
547
548 <span class='kw'>def</span> <span class='id identifier rubyid_set_current_track'>set_current_track</span>
549 <span class='ivar'>@current_track</span> <span class='op'>=</span> <span class='ivar'>@source_manager</span><span class='period'>.</span><span class='id identifier rubyid_current_track'>current_track</span>
550 <span class='kw'>end</span></pre>
551 </td>
552 </tr>
553 </table>
554 </div>
555
556 </div>
557
558 </div>
559
560 <div id="footer">
561 Generated on Sat Oct 6 03:20:24 2012 by
562 <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
563 0.8.2.1 (ruby-1.9.2).
564 </div>
565
566 </body>
567 </html>