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">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
7 Class: Lyricli::Lyricli
9 — Documentation by YARD
0.8.2.1
13 <link rel=
"stylesheet" href=
"../css/style.css" type=
"text/css" media=
"screen" charset=
"utf-8" />
15 <link rel=
"stylesheet" href=
"../css/common.css" type=
"text/css" media=
"screen" charset=
"utf-8" />
17 <script type=
"text/javascript" charset=
"utf-8">
18 hasFrames = window.top.frames.main ? true : false;
20 framesUrl = "../frames.html#!" + escape(window.location.href);
24 <script type=
"text/javascript" charset=
"utf-8" src=
"../js/jquery.js"></script>
26 <script type=
"text/javascript" charset=
"utf-8" src=
"../js/app.js"></script>
34 <a href=
"../_index.html">Index (L)
</a> »
35 <span class='title'
><span class='object_link'
><a href=
"../Lyricli.html" title=
"Lyricli (module)">Lyricli
</a></span></span>
37 <span class=
"title">Lyricli
</span>
40 <div class=
"noframes"><span class=
"title">(
</span><a href=
"." target=
"_top">no frames
</a><span class=
"title">)
</span></div>
45 <a class=
"full_list_link" id=
"class_list_link"
46 href=
"../class_list.html">
50 <a class=
"full_list_link" id=
"method_list_link"
51 href=
"../method_list.html">
55 <a class=
"full_list_link" id=
"file_list_link"
56 href=
"../file_list.html">
61 <div class=
"clear"></div>
64 <iframe id=
"search_frame"></iframe>
66 <div id=
"content"><h1>Class: Lyricli::Lyricli
74 <dt class=
"r1">Inherits:
</dt>
76 <span class=
"inheritName">Object
</span>
81 <li class=
"next">Lyricli::Lyricli
</li>
84 <a href=
"#" class=
"inheritanceTree">show all
</a>
96 <dt class=
"r2 last">Defined in:
</dt>
97 <dd class=
"r2 last">lib/lyricli/lyricli.rb
</dd>
100 <div class=
"clear"></div>
102 <h2>Overview
</h2><div class=
"docstring">
103 <div class=
"discussion">
105 This class has the basic logic for extracting the lyrics and controlling
124 Instance Method Summary
125 <small>(
<a href=
"#" class=
"summary_toggle">collapse
</a>)
</small>
131 <span class=
"summary_signature">
133 <a href=
"#check_params-instance_method" title=
"#check_params (instance method)">- (Object)
<strong>check_params
</strong> </a>
147 <span class=
"summary_desc"><div class='inline'
><p>
148 Exits with error when there is an empty field from the current track.
156 <span class=
"summary_signature">
158 <a href=
"#exit_with_error-instance_method" title=
"#exit_with_error (instance method)">- (Object)
<strong>exit_with_error
</strong> </a>
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.
182 <span class=
"summary_signature">
184 <a href=
"#get_lyrics-instance_method" title=
"#get_lyrics (instance method)">- (String)
<strong>get_lyrics
</strong> </a>
198 <span class=
"summary_desc"><div class='inline'
><p>
199 Extracts the current track, validates it and requests the lyrics from our
208 <span class=
"summary_signature">
210 <a href=
"#initialize-instance_method" title=
"#initialize (instance method)">- (Lyricli)
<strong>initialize
</strong> </a>
217 <span class=
"note title constructor">constructor
</span>
226 <span class=
"summary_desc"><div class='inline'
><p>
227 Constructor, initializes `@source_manager`.
235 <span class=
"summary_signature">
237 <a href=
"#set_current_track-instance_method" title=
"#set_current_track (instance method)">- (Object)
<strong>set_current_track
</strong> </a>
251 <span class=
"summary_desc"><div class='inline'
><p>
252 Set the `@current_track` instance variable by asking the SourceManager for
263 <div id=
"constructor_details" class=
"method_details_list">
264 <h2>Constructor Details
</h2>
266 <div class=
"method_details first">
267 <h3 class=
"signature first" id=
"initialize-instance_method">
269 - (
<tt><span class='object_link'
><a href=
"" title=
"Lyricli::Lyricli (class)">Lyricli
</a></span></tt>)
<strong>initialize
</strong>
275 </h3><div class=
"docstring">
276 <div class=
"discussion">
278 Constructor, initializes `@source_manager`
287 </div><table class=
"source_code">
298 <pre class=
"code"><span class=
"info file"># File 'lib/lyricli/lyricli.rb', line
8</span>
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>
311 <div id=
"instance_method_details" class=
"method_details_list">
312 <h2>Instance Method Details
</h2>
315 <div class=
"method_details first">
316 <h3 class=
"signature first" id=
"check_params-instance_method">
318 - (
<tt>Object
</tt>)
<strong>check_params
</strong>
324 </h3><div class=
"docstring">
325 <div class=
"discussion">
327 Exits with error when there is an empty field from the current track.
336 </div><table class=
"source_code">
349 <pre class=
"code"><span class=
"info file"># File 'lib/lyricli/lyricli.rb', line
49</span>
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>
361 <div class=
"method_details ">
362 <h3 class=
"signature " id=
"exit_with_error-instance_method">
364 - (
<tt>Object
</tt>)
<strong>exit_with_error
</strong>
370 </h3><div class=
"docstring">
371 <div class=
"discussion">
373 Raises an InvalidLyricsError which means we did not get any valid
374 artist/song from any of the sources
382 <p class=
"tag_title">Raises:
</p>
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>
393 <div class='inline'
><p>
394 because we found nothing
402 </div><table class=
"source_code">
413 <pre class=
"code"><span class=
"info file"># File 'lib/lyricli/lyricli.rb', line
16</span>
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>
423 <div class=
"method_details ">
424 <h3 class=
"signature " id=
"get_lyrics-instance_method">
426 - (
<tt>String
</tt>)
<strong>get_lyrics
</strong>
432 </h3><div class=
"docstring">
433 <div class=
"discussion">
435 Extracts the current track, validates it and requests the lyrics from our
444 <p class=
"tag_title">Returns:
</p>
450 <span class='type'
>(
<tt>String
</tt>)
</span>
455 <div class='inline'
><p>
456 the found lyrics, or a string indicating none were found
464 </div><table class=
"source_code">
489 <pre class=
"code"><span class=
"info file"># File 'lib/lyricli/lyricli.rb', line
24</span>
491 <span class='kw'
>def
</span> <span class='id identifier rubyid_get_lyrics'
>get_lyrics
</span>
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'
>"</span><span class='tstring_content'
>No Artist/Song could be found :(
</span><span class='tstring_end'
>"</span></span>
498 <span class='kw'
>end
</span>
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>
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'
>"</span><span class='tstring_content'
>Lyrics not found :(
</span><span class='tstring_end'
>"</span></span>
506 <span class='kw'
>end
</span>
507 <span class='kw'
>end
</span></pre>
513 <div class=
"method_details ">
514 <h3 class=
"signature " id=
"set_current_track-instance_method">
516 - (
<tt>Object
</tt>)
<strong>set_current_track
</strong>
522 </h3><div class=
"docstring">
523 <div class=
"discussion">
525 Set the `@current_track` instance variable by asking the SourceManager for
535 </div><table class=
"source_code">
546 <pre class=
"code"><span class=
"info file"># File 'lib/lyricli/lyricli.rb', line
44</span>
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>
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).