]> git.r.bdr.sh - rbdr/lyricli.rb/blob - doc/Lyricli/SourceManager.html
Add dangling files
[rbdr/lyricli.rb] / doc / Lyricli / SourceManager.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::SourceManager
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 (S)</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">SourceManager</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::SourceManager
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::SourceManager</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/source_manager.rb</dd>
102
103 </dl>
104 <div class="clear"></div>
105
106 <h2>Overview</h2><div class="docstring">
107 <div class="discussion">
108 <p>
109 Manages the different sources. SourceManager is in charge of enabling and
110 disabling them, as well as getting the current track.
111 </p>
112
113
114 </div>
115 </div>
116 <div class="tags">
117
118
119 </div>
120
121
122
123
124
125
126
127 <h2>
128 Instance Method Summary
129 <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
130 </h2>
131
132 <ul class="summary">
133
134 <li class="public ">
135 <span class="summary_signature">
136
137 <a href="#available_sources-instance_method" title="#available_sources (instance method)">- (Array) <strong>available_sources</strong>(format = false) </a>
138
139
140
141 </span>
142
143
144
145
146
147
148
149
150
151 <span class="summary_desc"><div class='inline'><p>
152 Returns an array with the available sources.
153 </p>
154 </div></span>
155
156 </li>
157
158
159 <li class="public ">
160 <span class="summary_signature">
161
162 <a href="#current_track-instance_method" title="#current_track (instance method)">- (Hash) <strong>current_track</strong> </a>
163
164
165
166 </span>
167
168
169
170
171
172
173
174
175
176 <span class="summary_desc"><div class='inline'><p>
177 Iterates over every source to attempt to retrieve the current song.
178 </p>
179 </div></span>
180
181 </li>
182
183
184 <li class="public ">
185 <span class="summary_signature">
186
187 <a href="#disable-instance_method" title="#disable (instance method)">- (Object) <strong>disable</strong>(source_name) </a>
188
189
190
191 </span>
192
193
194
195
196
197
198
199
200
201 <span class="summary_desc"><div class='inline'><p>
202 Disables a source.
203 </p>
204 </div></span>
205
206 </li>
207
208
209 <li class="public ">
210 <span class="summary_signature">
211
212 <a href="#enable-instance_method" title="#enable (instance method)">- (Object) <strong>enable</strong>(source_name) </a>
213
214
215
216 </span>
217
218
219
220
221
222
223
224
225
226 <span class="summary_desc"><div class='inline'><p>
227 Enables a source.
228 </p>
229 </div></span>
230
231 </li>
232
233
234 <li class="public ">
235 <span class="summary_signature">
236
237 <a href="#format_sources-instance_method" title="#format_sources (instance method)">- (Array) <strong>format_sources</strong>(sources) </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 Adds a star to all members of the array that correspond to an active
253 source.
254 </p>
255 </div></span>
256
257 </li>
258
259
260 <li class="public ">
261 <span class="summary_signature">
262
263 <a href="#initialize-instance_method" title="#initialize (instance method)">- (SourceManager) <strong>initialize</strong> </a>
264
265
266
267 </span>
268
269
270 <span class="note title constructor">constructor</span>
271
272
273
274
275
276
277
278
279 <span class="summary_desc"><div class='inline'><p>
280 Creates a new instance of SourceManager.
281 </p>
282 </div></span>
283
284 </li>
285
286
287 <li class="public ">
288 <span class="summary_signature">
289
290 <a href="#reset-instance_method" title="#reset (instance method)">- (Object) <strong>reset</strong>(source_name) </a>
291
292
293
294 </span>
295
296
297
298
299
300
301
302
303
304 <span class="summary_desc"><div class='inline'><p>
305 Resets a source.
306 </p>
307 </div></span>
308
309 </li>
310
311
312 </ul>
313
314
315
316
317
318
319
320
321
322
323
324 <h3 class="inherited">Methods included from <span class='object_link'><a href="Util.html" title="Lyricli::Util (module)">Util</a></span></h3>
325 <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>
326 <div id="constructor_details" class="method_details_list">
327 <h2>Constructor Details</h2>
328
329 <div class="method_details first">
330 <h3 class="signature first" id="initialize-instance_method">
331
332 - (<tt><span class='object_link'><a href="" title="Lyricli::SourceManager (class)">SourceManager</a></span></tt>) <strong>initialize</strong>
333
334
335
336
337
338 </h3><div class="docstring">
339 <div class="discussion">
340 <p>
341 Creates a new instance of SourceManager
342 </p>
343
344
345 </div>
346 </div>
347 <div class="tags">
348
349
350 </div><table class="source_code">
351 <tr>
352 <td>
353 <pre class="lines">
354
355
356 10
357 11
358 12
359 13
360 14
361 15
362 16
363 17
364 18
365 19
366 20
367 21</pre>
368 </td>
369 <td>
370 <pre class="code"><span class="info file"># File 'lib/lyricli/source_manager.rb', line 10</span>
371
372 <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
373 <span class='ivar'>@enabled_sources</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
374 <span class='ivar'>@config</span> <span class='op'>=</span> <span class='const'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
375 <span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>enabled_sources</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</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_source'>source</span><span class='op'>|</span>
376 <span class='kw'>if</span> <span class='id identifier rubyid_klass'>klass</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_class'>parse_class</span><span class='lparen'>(</span><span class='id identifier rubyid_camelize'>camelize</span><span class='lparen'>(</span><span class='id identifier rubyid_source'>source</span><span class='rparen'>)</span><span class='rparen'>)</span>
377 <span class='id identifier rubyid_current_source'>current_source</span> <span class='op'>=</span> <span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
378 <span class='ivar'>@enabled_sources</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_current_source'>current_source</span>
379 <span class='kw'>else</span>
380 <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>StartSourceError</span>
381 <span class='kw'>end</span>
382 <span class='kw'>end</span>
383 <span class='kw'>end</span></pre>
384 </td>
385 </tr>
386 </table>
387 </div>
388
389 </div>
390
391
392 <div id="instance_method_details" class="method_details_list">
393 <h2>Instance Method Details</h2>
394
395
396 <div class="method_details first">
397 <h3 class="signature first" id="available_sources-instance_method">
398
399 - (<tt>Array</tt>) <strong>available_sources</strong>(format = false)
400
401
402
403
404
405 </h3><div class="docstring">
406 <div class="discussion">
407 <p>
408 Returns an array with the available sources. Optionally formats the result
409 so active sources are identified by an appended *
410 </p>
411
412
413 </div>
414 </div>
415 <div class="tags">
416 <p class="tag_title">Parameters:</p>
417 <ul class="param">
418
419 <li>
420
421 <span class='name'>format</span>
422
423
424 <span class='type'>(<tt>Boolean</tt>)</span>
425
426
427 <em class="default">(defaults to: <tt>false</tt>)</em>
428
429
430 &mdash;
431 <div class='inline'><p>
432 whether or not to render the stars for active sources.
433 </p>
434 </div>
435
436 </li>
437
438 </ul>
439
440 <p class="tag_title">Returns:</p>
441 <ul class="return">
442
443 <li>
444
445
446 <span class='type'>(<tt>Array</tt>)</span>
447
448
449
450 &mdash;
451 <div class='inline'><p>
452 the names of the currently available sources.
453 </p>
454 </div>
455
456 </li>
457
458 </ul>
459
460 </div><table class="source_code">
461 <tr>
462 <td>
463 <pre class="lines">
464
465
466 107
467 108
468 109
469 110
470 111
471 112
472 113
473 114
474 115
475 116
476 117
477 118
478 119
479 120
480 121
481 122</pre>
482 </td>
483 <td>
484 <pre class="code"><span class="info file"># File 'lib/lyricli/source_manager.rb', line 107</span>
485
486 <span class='kw'>def</span> <span class='id identifier rubyid_available_sources'>available_sources</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
487 <span class='id identifier rubyid_path_root'>path_root</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span><span class='rparen'>)</span>
488 <span class='id identifier rubyid_sources'>sources</span> <span class='op'>=</span> <span class='const'>Dir</span><span class='lbracket'>[</span><span class='id identifier rubyid_path_root'>path_root</span><span class='op'>+</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/sources/*.rb</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_s'>s</span><span class='op'>|</span>
489 <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_s'>s</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.rb</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
490 <span class='id identifier rubyid_name'>name</span>
491 <span class='rbrace'>}</span>
492
493 <span class='comment'># Remove arguments (Hack?) We don't want anybody to touch tihs one.
494 </span> <span class='id identifier rubyid_sources'>sources</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>arguments</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
495 <span class='kw'>if</span> <span class='id identifier rubyid_format'>format</span>
496 <span class='comment'># Add a star to denote enabled sources
497 </span> <span class='id identifier rubyid_format_sources'>format_sources</span><span class='lparen'>(</span><span class='id identifier rubyid_sources'>sources</span><span class='rparen'>)</span>
498 <span class='kw'>else</span>
499 <span class='id identifier rubyid_sources'>sources</span>
500 <span class='kw'>end</span>
501 <span class='kw'>end</span></pre>
502 </td>
503 </tr>
504 </table>
505 </div>
506
507 <div class="method_details ">
508 <h3 class="signature " id="current_track-instance_method">
509
510 - (<tt>Hash</tt>) <strong>current_track</strong>
511
512
513
514
515
516 </h3><div class="docstring">
517 <div class="discussion">
518 <p>
519 Iterates over every source to attempt to retrieve the current song.
520 </p>
521
522
523 </div>
524 </div>
525 <div class="tags">
526
527 <p class="tag_title">Returns:</p>
528 <ul class="return">
529
530 <li>
531
532
533 <span class='type'>(<tt>Hash</tt>)</span>
534
535
536
537 &mdash;
538 <div class='inline'><p>
539 the current track, has an `:artist` and `:song` key.
540 </p>
541 </div>
542
543 </li>
544
545 </ul>
546
547 </div><table class="source_code">
548 <tr>
549 <td>
550 <pre class="lines">
551
552
553 80
554 81
555 82
556 83
557 84
558 85
559 86
560 87
561 88
562 89
563 90
564 91
565 92
566 93
567 94
568 95
569 96
570 97
571 98
572 99</pre>
573 </td>
574 <td>
575 <pre class="code"><span class="info file"># File 'lib/lyricli/source_manager.rb', line 80</span>
576
577 <span class='kw'>def</span> <span class='id identifier rubyid_current_track'>current_track</span>
578 <span class='id identifier rubyid_track'>track</span> <span class='op'>=</span> <span class='kw'>nil</span>
579 <span class='id identifier rubyid_lock'>lock</span> <span class='op'>=</span> <span class='kw'>false</span>
580 <span class='ivar'>@enabled_sources</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_source'>source</span><span class='op'>|</span>
581 <span class='kw'>begin</span>
582 <span class='id identifier rubyid_current_track'>current_track</span> <span class='op'>=</span> <span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_current_track'>current_track</span>
583
584 <span class='comment'># This is a special thing for arguments. The thing is, they need to
585 </span> <span class='comment'># be inputted manually. So, if they are present they won't allow
586 </span> <span class='comment'># anyone else to give results. Makes sense, yet a bit hacky.
587 </span> <span class='kw'>unless</span> <span class='id identifier rubyid_current_track'>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='op'>||</span> <span class='id identifier rubyid_current_track'>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> <span class='op'>||</span> <span class='id identifier rubyid_current_track'>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='op'>||</span> <span class='id identifier rubyid_current_track'>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>
588 <span class='id identifier rubyid_track'>track</span> <span class='op'>=</span> <span class='id identifier rubyid_current_track'>current_track</span> <span class='kw'>unless</span> <span class='id identifier rubyid_lock'>lock</span>
589 <span class='id identifier rubyid_lock'>lock</span> <span class='op'>=</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>arguments</span><span class='tstring_end'>&quot;</span></span>
590 <span class='kw'>end</span>
591 <span class='kw'>rescue</span>
592 <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>SourceConfigurationError</span>
593 <span class='kw'>end</span>
594 <span class='kw'>end</span>
595 <span class='id identifier rubyid_track'>track</span>
596 <span class='kw'>end</span></pre>
597 </td>
598 </tr>
599 </table>
600 </div>
601
602 <div class="method_details ">
603 <h3 class="signature " id="disable-instance_method">
604
605 - (<tt>Object</tt>) <strong>disable</strong>(source_name)
606
607
608
609
610
611 </h3><div class="docstring">
612 <div class="discussion">
613 <p>
614 Disables a source. This only removes the source from the `enabled_sources`
615 configuration key.
616 </p>
617
618
619 </div>
620 </div>
621 <div class="tags">
622 <p class="tag_title">Parameters:</p>
623 <ul class="param">
624
625 <li>
626
627 <span class='name'>source_name</span>
628
629
630 <span class='type'>(<tt>String</tt>)</span>
631
632
633
634 &mdash;
635 <div class='inline'><p>
636 the name of the source to disable
637 </p>
638 </div>
639
640 </li>
641
642 </ul>
643
644
645 </div><table class="source_code">
646 <tr>
647 <td>
648 <pre class="lines">
649
650
651 47
652 48
653 49
654 50
655 51
656 52
657 53
658 54
659 55
660 56
661 57
662 58</pre>
663 </td>
664 <td>
665 <pre class="code"><span class="info file"># File 'lib/lyricli/source_manager.rb', line 47</span>
666
667 <span class='kw'>def</span> <span class='id identifier rubyid_disable'>disable</span><span class='lparen'>(</span><span class='id identifier rubyid_source_name'>source_name</span><span class='rparen'>)</span>
668 <span class='kw'>if</span> <span class='id identifier rubyid_available_sources'>available_sources</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_source_name'>source_name</span><span class='rparen'>)</span>
669 <span class='kw'>if</span> <span class='id identifier rubyid_klass'>klass</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_class'>parse_class</span><span class='lparen'>(</span><span class='id identifier rubyid_camelize'>camelize</span><span class='lparen'>(</span><span class='id identifier rubyid_source_name'>source_name</span><span class='rparen'>)</span><span class='rparen'>)</span>
670 <span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>enabled_sources</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
671 <span class='ivar'>@config</span><span class='period'>.</span><span class='id identifier rubyid_save_config'>save_config</span>
672 <span class='kw'>else</span>
673 <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>DisableSourceError</span>
674 <span class='kw'>end</span>
675 <span class='kw'>else</span>
676 <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>UnknownSourceError</span>
677 <span class='kw'>end</span>
678 <span class='kw'>end</span></pre>
679 </td>
680 </tr>
681 </table>
682 </div>
683
684 <div class="method_details ">
685 <h3 class="signature " id="enable-instance_method">
686
687 - (<tt>Object</tt>) <strong>enable</strong>(source_name)
688
689
690
691
692
693 </h3><div class="docstring">
694 <div class="discussion">
695 <p>
696 Enables a source. This runs the source&#8217;s enable method and adds it to
697 the `enabled_sources` configuration key. It will only enable sources that
698 are &#8220;available&#8221; (see #available_sources)
699 </p>
700
701
702 </div>
703 </div>
704 <div class="tags">
705 <p class="tag_title">Parameters:</p>
706 <ul class="param">
707
708 <li>
709
710 <span class='name'>source_name</span>
711
712
713 <span class='type'>(<tt>String</tt>)</span>
714
715
716
717 &mdash;
718 <div class='inline'><p>
719 the name of the source to enable
720 </p>
721 </div>
722
723 </li>
724
725 </ul>
726
727
728 </div><table class="source_code">
729 <tr>
730 <td>
731 <pre class="lines">
732
733
734 28
735 29
736 30
737 31
738 32
739 33
740 34
741 35
742 36
743 37
744 38
745 39
746 40
747 41</pre>
748 </td>
749 <td>
750 <pre class="code"><span class="info file"># File 'lib/lyricli/source_manager.rb', line 28</span>
751
752 <span class='kw'>def</span> <span class='id identifier rubyid_enable'>enable</span><span class='lparen'>(</span><span class='id identifier rubyid_source_name'>source_name</span><span class='rparen'>)</span>
753 <span class='kw'>if</span> <span class='id identifier rubyid_available_sources'>available_sources</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_source_name'>source_name</span><span class='rparen'>)</span>
754 <span class='kw'>if</span> <span class='id identifier rubyid_klass'>klass</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_class'>parse_class</span><span class='lparen'>(</span><span class='id identifier rubyid_camelize'>camelize</span><span class='lparen'>(</span><span class='id identifier rubyid_source_name'>source_name</span><span class='rparen'>)</span><span class='rparen'>)</span>
755 <span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_enable'>enable</span>
756 <span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>enabled_sources</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span>
757 <span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>enabled_sources</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_uniq!'>uniq!</span>
758 <span class='ivar'>@config</span><span class='period'>.</span><span class='id identifier rubyid_save_config'>save_config</span>
759 <span class='kw'>else</span>
760 <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>EnableSourceError</span>
761 <span class='kw'>end</span>
762 <span class='kw'>else</span>
763 <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>UnknownSourceError</span>
764 <span class='kw'>end</span>
765 <span class='kw'>end</span></pre>
766 </td>
767 </tr>
768 </table>
769 </div>
770
771 <div class="method_details ">
772 <h3 class="signature " id="format_sources-instance_method">
773
774 - (<tt>Array</tt>) <strong>format_sources</strong>(sources)
775
776
777
778
779
780 </h3><div class="docstring">
781 <div class="discussion">
782 <p>
783 Adds a star to all members of the array that correspond to an active source
784 </p>
785
786
787 </div>
788 </div>
789 <div class="tags">
790 <p class="tag_title">Parameters:</p>
791 <ul class="param">
792
793 <li>
794
795 <span class='name'>sources</span>
796
797
798 <span class='type'>(<tt>Array</tt>)</span>
799
800
801
802 &mdash;
803 <div class='inline'><p>
804 the array of sources to format
805 </p>
806 </div>
807
808 </li>
809
810 </ul>
811
812 <p class="tag_title">Returns:</p>
813 <ul class="return">
814
815 <li>
816
817
818 <span class='type'>(<tt>Array</tt>)</span>
819
820
821
822 &mdash;
823 <div class='inline'><p>
824 the formatted array
825 </p>
826 </div>
827
828 </li>
829
830 </ul>
831
832 </div><table class="source_code">
833 <tr>
834 <td>
835 <pre class="lines">
836
837
838 129
839 130
840 131
841 132
842 133
843 134</pre>
844 </td>
845 <td>
846 <pre class="code"><span class="info file"># File 'lib/lyricli/source_manager.rb', line 129</span>
847
848 <span class='kw'>def</span> <span class='id identifier rubyid_format_sources'>format_sources</span><span class='lparen'>(</span><span class='id identifier rubyid_sources'>sources</span><span class='rparen'>)</span>
849 <span class='id identifier rubyid_sources'>sources</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_s'>s</span><span class='op'>|</span>
850 <span class='id identifier rubyid_s'>s</span> <span class='op'>&lt;&lt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>*</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>enabled_sources</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='rparen'>)</span>
851 <span class='id identifier rubyid_s'>s</span>
852 <span class='rbrace'>}</span>
853 <span class='kw'>end</span></pre>
854 </td>
855 </tr>
856 </table>
857 </div>
858
859 <div class="method_details ">
860 <h3 class="signature " id="reset-instance_method">
861
862 - (<tt>Object</tt>) <strong>reset</strong>(source_name)
863
864
865
866
867
868 </h3><div class="docstring">
869 <div class="discussion">
870 <p>
871 Resets a source. This runs the source&#8217;s reset method. It will also
872 disable them.
873 </p>
874
875
876 </div>
877 </div>
878 <div class="tags">
879 <p class="tag_title">Parameters:</p>
880 <ul class="param">
881
882 <li>
883
884 <span class='name'>source_name</span>
885
886
887 <span class='type'>(<tt>String</tt>)</span>
888
889
890
891 &mdash;
892 <div class='inline'><p>
893 the name of the source to reset.
894 </p>
895 </div>
896
897 </li>
898
899 </ul>
900
901
902 </div><table class="source_code">
903 <tr>
904 <td>
905 <pre class="lines">
906
907
908 64
909 65
910 66
911 67
912 68
913 69
914 70
915 71
916 72
917 73
918 74
919 75</pre>
920 </td>
921 <td>
922 <pre class="code"><span class="info file"># File 'lib/lyricli/source_manager.rb', line 64</span>
923
924 <span class='kw'>def</span> <span class='id identifier rubyid_reset'>reset</span><span class='lparen'>(</span><span class='id identifier rubyid_source_name'>source_name</span><span class='rparen'>)</span>
925 <span class='kw'>if</span> <span class='id identifier rubyid_available_sources'>available_sources</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_source_name'>source_name</span><span class='rparen'>)</span>
926 <span class='kw'>if</span> <span class='id identifier rubyid_klass'>klass</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_class'>parse_class</span><span class='lparen'>(</span><span class='id identifier rubyid_camelize'>camelize</span><span class='lparen'>(</span><span class='id identifier rubyid_source_name'>source_name</span><span class='rparen'>)</span><span class='rparen'>)</span>
927 <span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_reset'>reset</span>
928 <span class='id identifier rubyid_disable'>disable</span><span class='lparen'>(</span><span class='id identifier rubyid_source_name'>source_name</span><span class='rparen'>)</span>
929 <span class='kw'>else</span>
930 <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>ResetSourceError</span>
931 <span class='kw'>end</span>
932 <span class='kw'>else</span>
933 <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>UnknownSourceError</span>
934 <span class='kw'>end</span>
935 <span class='kw'>end</span></pre>
936 </td>
937 </tr>
938 </table>
939 </div>
940
941 </div>
942
943 </div>
944
945 <div id="footer">
946 Generated on Sat Oct 6 03:20:24 2012 by
947 <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
948 0.8.2.1 (ruby-1.9.2).
949 </div>
950
951 </body>
952 </html>