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.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">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>
106 <h2>Overview
</h2><div class=
"docstring">
107 <div class=
"discussion">
109 This class gets the lyrics according to a given artist and song name.
127 Instance Method Summary
128 <small>(
<a href=
"#" class=
"summary_toggle">collapse
</a>)
</small>
134 <span class=
"summary_signature">
136 <a href=
"#get_lyrics-instance_method" title=
"#get_lyrics (instance method)">- (String)
<strong>get_lyrics
</strong> </a>
150 <span class=
"summary_desc"><div class='inline'
><p>
151 Asks Lyrics Wiki for the lyrics, also cleans up the output a little.
159 <span class=
"summary_signature">
161 <a href=
"#initialize-instance_method" title=
"#initialize (instance method)">- (LyricsEngine)
<strong>initialize
</strong>(artist, song)
</a>
168 <span class=
"note title constructor">constructor
</span>
177 <span class=
"summary_desc"><div class='inline'
><p>
178 Starts a new instance of LyricsEngine.
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>
202 <div class=
"method_details first">
203 <h3 class=
"signature first" id=
"initialize-instance_method">
205 - (
<tt><span class='object_link'
><a href=
"" title=
"Lyricli::LyricsEngine (class)">LyricsEngine
</a></span></tt>)
<strong>initialize
</strong>(artist, song)
211 </h3><div class=
"docstring">
212 <div class=
"discussion">
214 Starts a new instance of LyricsEngine
221 <p class=
"tag_title">Parameters:
</p>
226 <span class='name'
>artist
</span>
229 <span class='type'
>(
<tt>String
</tt>)
</span>
234 <div class='inline'
><p>
243 <span class='name'
>song
</span>
246 <span class='type'
>(
<tt>String
</tt>)
</span>
251 <div class='inline'
><p>
261 </div><table class=
"source_code">
272 <pre class=
"code"><span class=
"info file"># File 'lib/lyricli/lyrics_engine.rb', line
12</span>
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'
>"</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>
276 <span class='kw'
>end
</span></pre>
285 <div id=
"instance_method_details" class=
"method_details_list">
286 <h2>Instance Method Details
</h2>
289 <div class=
"method_details first">
290 <h3 class=
"signature first" id=
"get_lyrics-instance_method">
292 - (
<tt>String
</tt>)
<strong>get_lyrics
</strong>
298 </h3><div class=
"docstring">
299 <div class=
"discussion">
301 Asks Lyrics Wiki for the lyrics, also cleans up the output a little.
309 <p class=
"tag_title">Returns:
</p>
315 <span class='type'
>(
<tt>String
</tt>)
</span>
320 <div class='inline'
><p>
329 </div><table class=
"source_code">
358 <pre class=
"code"><span class=
"info file"># File 'lib/lyricli/lyrics_engine.rb', line
19</span>
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>
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'
>"</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>
367 <span class='kw'
>rescue
</span>
368 <span class='id identifier rubyid_raise'
>raise
</span> <span class='const'
>Exceptions
</span><span class='op'
>::
</span><span class='const'
>LyricsNotFoundError
</span>
369 <span class='kw'
>end
</span>
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'
>"</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>
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>
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'
>"</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>
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'
>"</span><span class='tstring_content'
>\n
</span><span class='tstring_end'
>"</span></span>
377 <span class='kw'
>end
</span>
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>
391 Generated on Sat Oct
6 03:
20:
24 2012 by
392 <a href=
"http://yardoc.org" title=
"Yay! A Ruby Documentation Tool" target=
"_parent">yard
</a>
393 0.8.2.1 (ruby-
1.9.2).