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::LyricsEngine
9 — Documentation by YARD
0.8.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">LyricsEngine
</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::LyricsEngine
74 <dt class=
"r1">Inherits:
</dt>
76 <span class=
"inheritName">Object
</span>
81 <li class=
"next">Lyricli::LyricsEngine
</li>
84 <a href=
"#" class=
"inheritanceTree">show all
</a>
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>
100 <dt class=
"r1 last">Defined in:
</dt>
101 <dd class=
"r1 last">lib/lyricli/lyrics_engine.rb
</dd>
104 <div class=
"clear"></div>
115 Instance Method Summary
116 <small>(
<a href=
"#" class=
"summary_toggle">collapse
</a>)
</small>
122 <span class=
"summary_signature">
124 <a href=
"#get_lyrics-instance_method" title=
"#get_lyrics (instance method)">- (Object)
<strong>get_lyrics
</strong> </a>
138 <span class=
"summary_desc"><div class='inline'
></div></span>
144 <span class=
"summary_signature">
146 <a href=
"#initialize-instance_method" title=
"#initialize (instance method)">- (LyricsEngine)
<strong>initialize
</strong>(artist, song)
</a>
153 <span class=
"note title constructor">constructor
</span>
162 <span class=
"summary_desc"><div class='inline'
><p>
163 A new instance of LyricsEngine.
182 <h3 class=
"inherited">Methods included from
<span class='object_link'
><a href=
"Util.html" title=
"Lyricli::Util (module)">Util
</a></span></h3>
183 <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>
184 <div id=
"constructor_details" class=
"method_details_list">
185 <h2>Constructor Details
</h2>
187 <div class=
"method_details first">
188 <h3 class=
"signature first" id=
"initialize-instance_method">
190 - (
<tt><span class='object_link'
><a href=
"" title=
"Lyricli::LyricsEngine (class)">LyricsEngine
</a></span></tt>)
<strong>initialize
</strong>(artist, song)
196 </h3><div class=
"docstring">
197 <div class=
"discussion">
199 A new instance of LyricsEngine
208 </div><table class=
"source_code">
219 <pre class=
"code"><span class=
"info file"># File 'lib/lyricli/lyrics_engine.rb', line
6</span>
221 <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>
222 <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'
>"</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'
>&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'
>&fmt=realjson
</span><span class='tstring_end'
>"</span></span><span class='rparen'
>)
</span>
223 <span class='kw'
>end
</span></pre>
232 <div id=
"instance_method_details" class=
"method_details_list">
233 <h2>Instance Method Details
</h2>
236 <div class=
"method_details first">
237 <h3 class=
"signature first" id=
"get_lyrics-instance_method">
239 - (
<tt>Object
</tt>)
<strong>get_lyrics
</strong>
245 </h3><table class=
"source_code">
274 <pre class=
"code"><span class=
"info file"># File 'lib/lyricli/lyrics_engine.rb', line
10</span>
276 <span class='kw'
>def
</span> <span class='id identifier rubyid_get_lyrics'
>get_lyrics
</span>
277 <span class='kw'
>begin
</span>
278 <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>
279 <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>
281 <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>
282 <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'
>"</span><span class='tstring_content'
>.lyricbox
</span><span class='tstring_end'
>"</span></span><span class='rparen'
>)
</span><span class='period'
>.
</span><span class='id identifier rubyid_first'
>first
</span>
283 <span class='kw'
>rescue
</span>
284 <span class='id identifier rubyid_raise'
>raise
</span> <span class='const'
>Lyricli
</span><span class='op'
>::
</span><span class='const'
>LyricsNotFoundException
</span>
285 <span class='kw'
>end
</span>
287 <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'
>"</span><span class='tstring_content'
>.rtMatcher
</span><span class='tstring_end'
>"</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>
288 <span class='id identifier rubyid_n'
>n
</span><span class='period'
>.
</span><span class='id identifier rubyid_remove'
>remove
</span>
289 <span class='kw'
>end
</span>
291 <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'
>"</span><span class='tstring_content'
>br
</span><span class='tstring_end'
>"</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>
292 <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'
>"</span><span class='tstring_content'
>\n
</span><span class='tstring_end'
>"</span></span>
293 <span class='kw'
>end
</span>
295 <span class='id identifier rubyid_node'
>node
</span><span class='period'
>.
</span><span class='id identifier rubyid_inner_text'
>inner_text
</span>
296 <span class='kw'
>end
</span></pre>
307 Generated on Fri Oct
5 22:
31:
14 2012 by
308 <a href=
"http://yardoc.org" title=
"Yay! A Ruby Documentation Tool" target=
"_parent">yard
</a>