]>
Commit | Line | Data |
---|---|---|
823e558b BB |
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::LyricsEngine | |
8 | ||
9 | — Documentation by YARD 0.8.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> » | |
35 | <span class='title'><span class='object_link'><a href="../Lyricli.html" title="Lyricli (module)">Lyricli</a></span></span> | |
36 | » | |
37 | <span class="title">LyricsEngine</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::LyricsEngine | |
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::LyricsEngine</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/lyrics_engine.rb</dd> | |
102 | ||
103 | </dl> | |
104 | <div class="clear"></div> | |
105 | ||
106 | ||
107 | ||
108 | ||
109 | ||
110 | ||
111 | ||
112 | ||
113 | ||
114 | <h2> | |
115 | Instance Method Summary | |
116 | <small>(<a href="#" class="summary_toggle">collapse</a>)</small> | |
117 | </h2> | |
118 | ||
119 | <ul class="summary"> | |
120 | ||
121 | <li class="public "> | |
122 | <span class="summary_signature"> | |
123 | ||
124 | <a href="#get_lyrics-instance_method" title="#get_lyrics (instance method)">- (Object) <strong>get_lyrics</strong> </a> | |
125 | ||
126 | ||
127 | ||
128 | </span> | |
129 | ||
130 | ||
131 | ||
132 | ||
133 | ||
134 | ||
135 | ||
136 | ||
137 | ||
138 | <span class="summary_desc"><div class='inline'></div></span> | |
139 | ||
140 | </li> | |
141 | ||
142 | ||
143 | <li class="public "> | |
144 | <span class="summary_signature"> | |
145 | ||
146 | <a href="#initialize-instance_method" title="#initialize (instance method)">- (LyricsEngine) <strong>initialize</strong>(artist, song) </a> | |
147 | ||
148 | ||
149 | ||
150 | </span> | |
151 | ||
152 | ||
153 | <span class="note title constructor">constructor</span> | |
154 | ||
155 | ||
156 | ||
157 | ||
158 | ||
159 | ||
160 | ||
161 | ||
162 | <span class="summary_desc"><div class='inline'><p> | |
163 | A new instance of LyricsEngine. | |
164 | </p> | |
165 | </div></span> | |
166 | ||
167 | </li> | |
168 | ||
169 | ||
170 | </ul> | |
171 | ||
172 | ||
173 | ||
174 | ||
175 | ||
176 | ||
177 | ||
178 | ||
179 | ||
180 | ||
181 | ||
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> | |
186 | ||
187 | <div class="method_details first"> | |
188 | <h3 class="signature first" id="initialize-instance_method"> | |
189 | ||
190 | - (<tt><span class='object_link'><a href="" title="Lyricli::LyricsEngine (class)">LyricsEngine</a></span></tt>) <strong>initialize</strong>(artist, song) | |
191 | ||
192 | ||
193 | ||
194 | ||
195 | ||
196 | </h3><div class="docstring"> | |
197 | <div class="discussion"> | |
198 | <p> | |
199 | A new instance of LyricsEngine | |
200 | </p> | |
201 | ||
202 | ||
203 | </div> | |
204 | </div> | |
205 | <div class="tags"> | |
206 | ||
207 | ||
208 | </div><table class="source_code"> | |
209 | <tr> | |
210 | <td> | |
211 | <pre class="lines"> | |
212 | ||
213 | ||
214 | 6 | |
215 | 7 | |
216 | 8</pre> | |
217 | </td> | |
218 | <td> | |
219 | <pre class="code"><span class="info file"># File 'lib/lyricli/lyrics_engine.rb', line 6</span> | |
220 | ||
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> | |
224 | </td> | |
225 | </tr> | |
226 | </table> | |
227 | </div> | |
228 | ||
229 | </div> | |
230 | ||
231 | ||
232 | <div id="instance_method_details" class="method_details_list"> | |
233 | <h2>Instance Method Details</h2> | |
234 | ||
235 | ||
236 | <div class="method_details first"> | |
237 | <h3 class="signature first" id="get_lyrics-instance_method"> | |
238 | ||
239 | - (<tt>Object</tt>) <strong>get_lyrics</strong> | |
240 | ||
241 | ||
242 | ||
243 | ||
244 | ||
245 | </h3><table class="source_code"> | |
246 | <tr> | |
247 | <td> | |
248 | <pre class="lines"> | |
249 | ||
250 | ||
251 | 10 | |
252 | 11 | |
253 | 12 | |
254 | 13 | |
255 | 14 | |
256 | 15 | |
257 | 16 | |
258 | 17 | |
259 | 18 | |
260 | 19 | |
261 | 20 | |
262 | 21 | |
263 | 22 | |
264 | 23 | |
265 | 24 | |
266 | 25 | |
267 | 26 | |
268 | 27 | |
269 | 28 | |
270 | 29 | |
271 | 30</pre> | |
272 | </td> | |
273 | <td> | |
274 | <pre class="code"><span class="info file"># File 'lib/lyricli/lyrics_engine.rb', line 10</span> | |
275 | ||
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> | |
280 | ||
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> | |
286 | ||
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> | |
290 | ||
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> | |
294 | ||
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> | |
297 | </td> | |
298 | </tr> | |
299 | </table> | |
300 | </div> | |
301 | ||
302 | </div> | |
303 | ||
304 | </div> | |
305 | ||
306 | <div id="footer"> | |
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> | |
309 | 0.8.1 (ruby-1.9.2). | |
310 | </div> | |
311 | ||
312 | </body> | |
313 | </html> |