329 lines
No EOL
12 KiB
HTML
329 lines
No EOL
12 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>
|
|
Module: YoutubeTitles
|
|
|
|
— Documentation by YARD 0.7.1
|
|
|
|
</title>
|
|
|
|
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
|
|
|
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
|
|
|
<script type="text/javascript" charset="utf-8">
|
|
relpath = '';
|
|
if (relpath != '') relpath += '/';
|
|
</script>
|
|
|
|
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
|
|
|
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
|
|
|
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript" charset="utf-8">
|
|
if (window.top.frames.main) document.body.className = 'frames';
|
|
</script>
|
|
|
|
<div id="header">
|
|
<div id="menu">
|
|
|
|
<a href="_index.html">Index (Y)</a> »
|
|
|
|
|
|
<span class="title">YoutubeTitles</span>
|
|
|
|
|
|
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
|
</div>
|
|
|
|
<div id="search">
|
|
|
|
<a id="class_list_link" href="#">Class List</a>
|
|
|
|
<a id="method_list_link" href="#">Method List</a>
|
|
|
|
<a id="file_list_link" href="#">File List</a>
|
|
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>
|
|
|
|
<iframe id="search_frame"></iframe>
|
|
|
|
<div id="content"><h1>Module: YoutubeTitles
|
|
|
|
|
|
|
|
</h1>
|
|
|
|
<dl class="box">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dt class="r1">Included in:</dt>
|
|
<dd class="r1"><span class='object_link'><a href="Comment.html" title="Comment (class)">Comment</a></span>, <span class='object_link'><a href="StatusMessage.html" title="StatusMessage (class)">StatusMessage</a></span></dd>
|
|
|
|
|
|
|
|
<dt class="r2 last">Defined in:</dt>
|
|
<dd class="r2 last">lib/youtube_titles.rb</dd>
|
|
|
|
</dl>
|
|
<div class="clear"></div>
|
|
|
|
|
|
<h2>Constant Summary</h2>
|
|
|
|
<dl class="constants">
|
|
|
|
<dt id="YOUTUBE_ID_REGEX-constant" class="">YOUTUBE_ID_REGEX =
|
|
|
|
</dt>
|
|
<dd><pre class="code"><span class='regexp val'>/(?:https?:\/\/)(?:youtu\.be\/|(?:[a-z]{2,3}\.)?youtube\.com\/watch(?:\?|#!|.+&|.+&amp;)v=)([\w-]{11})(?:\S*(#[^ ]+)|\S+)?/i</span><span class='m identifier id'>m</span> <span class='unless unless_mod kw'>unless</span> <span class='defined? defined kw'>defined?</span> <span class='YOUTUBE_ID_REGEX constant id'>YOUTUBE_ID_REGEX</span>
|
|
</pre></dd>
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2>
|
|
Class Method Summary
|
|
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
|
</h2>
|
|
|
|
<ul class="summary">
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#included-class_method" title="included (class method)">+ (Object) <strong>included</strong>(model) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
<h2>
|
|
Instance Method Summary
|
|
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
|
</h2>
|
|
|
|
<ul class="summary">
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#get_youtube_title-instance_method" title="#get_youtube_title (instance method)">- (Object) <strong>get_youtube_title</strong>(text) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#youtube_title_for-instance_method" title="#youtube_title_for (instance method)">- (Object) <strong>youtube_title_for</strong>(video_id) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<div id="class_method_details" class="method_details_list">
|
|
<h2>Class Method Details</h2>
|
|
|
|
|
|
<div class="method_details first">
|
|
<p class="signature first" id="included-class_method">
|
|
|
|
+ (<tt>Object</tt>) <strong>included</strong>(model)
|
|
|
|
|
|
|
|
</p><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/youtube_titles.rb', line 2</span>
|
|
|
|
<span class='def def kw'>def</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='included identifier id'>included</span><span class='lparen token'>(</span><span class='model identifier id'>model</span><span class='rparen token'>)</span>
|
|
<span class='model identifier id'>model</span><span class='dot token'>.</span><span class='class_eval identifier id'>class_eval</span> <span class='do do kw'>do</span>
|
|
<span class='before_save identifier id'>before_save</span> <span class='do do kw'>do</span>
|
|
<span class='get_youtube_title identifier id'>get_youtube_title</span> <span class='text identifier id'>text</span>
|
|
<span class='end end kw'>end</span>
|
|
<span class='end end kw'>end</span> <span class='if if_mod kw'>if</span> <span class='model identifier id'>model</span><span class='dot token'>.</span><span class='respond_to? fid id'>respond_to?</span><span class='lparen token'>(</span><span class='symbol val'>:before_save</span><span class='rparen token'>)</span>
|
|
<span class='end end kw'>end</span>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="instance_method_details" class="method_details_list">
|
|
<h2>Instance Method Details</h2>
|
|
|
|
|
|
<div class="method_details first">
|
|
<p class="signature first" id="get_youtube_title-instance_method">
|
|
|
|
- (<tt>Object</tt>) <strong>get_youtube_title</strong>(text)
|
|
|
|
|
|
|
|
</p><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
|
28
|
|
29</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/youtube_titles.rb', line 21</span>
|
|
|
|
<span class='def def kw'>def</span> <span class='get_youtube_title identifier id'>get_youtube_title</span> <span class='text identifier id'>text</span>
|
|
<span class='youtube_match identifier id'>youtube_match</span> <span class='assign token'>=</span> <span class='text identifier id'>text</span><span class='dot token'>.</span><span class='enum_for identifier id'>enum_for</span><span class='lparen token'>(</span><span class='symbol val'>:scan</span><span class='comma token'>,</span> <span class='YOUTUBE_ID_REGEX constant id'>YOUTUBE_ID_REGEX</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='map identifier id'>map</span> <span class='lbrace token'>{</span> <span class='Regexp constant id'>Regexp</span><span class='dot token'>.</span><span class='last_match identifier id'>last_match</span> <span class='rbrace token'>}</span>
|
|
<span class='return return kw'>return</span> <span class='if if_mod kw'>if</span> <span class='youtube_match identifier id'>youtube_match</span><span class='dot token'>.</span><span class='empty? fid id'>empty?</span>
|
|
|
|
<span class='self self kw'>self</span><span class='dot token'>.</span><span class='youtube_titles identifier id'>youtube_titles</span> <span class='opasgn op'>||=</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span>
|
|
<span class='youtube_match identifier id'>youtube_match</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='match_data identifier id'>match_data</span><span class='bitor op'>|</span>
|
|
<span class='self self kw'>self</span><span class='dot token'>.</span><span class='youtube_titles identifier id'>youtube_titles</span><span class='lbrack token'>[</span><span class='match_data identifier id'>match_data</span><span class='lbrack token'>[</span><span class='integer val'>1</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='CGI constant id'>CGI</span><span class='colon2 op'>::</span><span class='escape identifier id'>escape</span><span class='lparen token'>(</span><span class='youtube_title_for identifier id'>youtube_title_for</span><span class='lparen token'>(</span><span class='match_data identifier id'>match_data</span><span class='lbrack token'>[</span><span class='integer val'>1</span><span class='rbrack token'>]</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
|
|
<span class='end end kw'>end</span>
|
|
<span class='end end kw'>end</span>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<p class="signature " id="youtube_title_for-instance_method">
|
|
|
|
- (<tt>Object</tt>) <strong>youtube_title_for</strong>(video_id)
|
|
|
|
|
|
|
|
</p><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/youtube_titles.rb', line 10</span>
|
|
|
|
<span class='def def kw'>def</span> <span class='youtube_title_for identifier id'>youtube_title_for</span> <span class='video_id identifier id'>video_id</span>
|
|
<span class='http identifier id'>http</span> <span class='assign token'>=</span> <span class='Net constant id'>Net</span><span class='colon2 op'>::</span><span class='HTTP constant id'>HTTP</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='string val'>'gdata.youtube.com'</span><span class='comma token'>,</span> <span class='integer val'>80</span><span class='rparen token'>)</span>
|
|
<span class='path identifier id'>path</span> <span class='assign token'>=</span> <span class='dstring node'>"/feeds/api/videos/#{video_id}?v=2"</span>
|
|
<span class='resp identifier id'>resp</span><span class='comma token'>,</span> <span class='data identifier id'>data</span> <span class='assign token'>=</span> <span class='http identifier id'>http</span><span class='dot token'>.</span><span class='get identifier id'>get</span><span class='lparen token'>(</span><span class='path identifier id'>path</span><span class='comma token'>,</span> <span class='nil nil kw'>nil</span><span class='rparen token'>)</span>
|
|
<span class='title identifier id'>title</span> <span class='assign token'>=</span> <span class='data identifier id'>data</span><span class='dot token'>.</span><span class='match identifier id'>match</span><span class='lparen token'>(</span><span class='regexp val'>/<title>(.*)<\/title>/</span><span class='rparen token'>)</span>
|
|
<span class='unless unless kw'>unless</span> <span class='title identifier id'>title</span><span class='dot token'>.</span><span class='nil? fid id'>nil?</span>
|
|
<span class='title identifier id'>title</span> <span class='assign token'>=</span> <span class='title identifier id'>title</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span><span class='lbrack token'>[</span><span class='float val'>7</span><span class='dot2 op'>..</span><span class='integer val'>-9</span><span class='rbrack token'>]</span>
|
|
<span class='end end kw'>end</span>
|
|
<span class='title identifier id'>title</span> <span class='orop op'>||</span> <span class='I18n constant id'>I18n</span><span class='dot token'>.</span><span class='t identifier id'>t</span><span class='lparen token'>(</span><span class='string val'>'application.helper.video_title.unknown'</span><span class='rparen token'>)</span>
|
|
<span class='end end kw'>end</span>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="footer">
|
|
Generated on Mon Jun 13 15:59:20 2011 by
|
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
0.7.1 (ruby-1.8.7).
|
|
</div>
|
|
|
|
</body>
|
|
</html> |