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" />
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 (U)
</a> »
35 <span class='title'
><span class='object_link'
><a href=
"../Lyricli.html" title=
"Lyricli (module)">Lyricli
</a></span></span>
37 <span class=
"title">Util
</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>Module: Lyricli::Util
80 <dt class=
"r1">Included in:
</dt>
81 <dd class=
"r1"><span class='object_link'
><a href=
"LyricsEngine.html" title=
"Lyricli::LyricsEngine (class)">LyricsEngine
</a></span>,
<span class='object_link'
><a href=
"SourceManager.html" title=
"Lyricli::SourceManager (class)">SourceManager
</a></span></dd>
85 <dt class=
"r2 last">Defined in:
</dt>
86 <dd class=
"r2 last">lib/lyricli/util.rb
</dd>
89 <div class=
"clear"></div>
91 <h2>Overview
</h2><div class=
"docstring">
92 <div class=
"discussion">
94 This module contains several utility functions.
112 Instance Method Summary
113 <small>(
<a href=
"#" class=
"summary_toggle">collapse
</a>)
</small>
119 <span class=
"summary_signature">
121 <a href=
"#camelize-instance_method" title=
"#camelize (instance method)">- (String)
<strong>camelize
</strong>(str)
</a>
135 <span class=
"summary_desc"><div class='inline'
><p>
136 Transforms a string from snake_case to UpperCamelCase.
144 <span class=
"summary_signature">
146 <a href=
"#parse_class-instance_method" title=
"#parse_class (instance method)">- (Class
<sup>?
</sup>)
<strong>parse_class
</strong>(class_name)
</a>
160 <span class=
"summary_desc"><div class='inline'
><p>
161 Takes a class name in snake_case and attempts to find the corresponding
162 class from the sources.
170 <span class=
"summary_signature">
172 <a href=
"#sanitize_param-instance_method" title=
"#sanitize_param (instance method)">- (String)
<strong>sanitize_param
</strong>(p)
</a>
186 <span class=
"summary_desc"><div class='inline'
><p>
187 Simply escapes a param and substitutes spaces and escaped plus signs for
200 <div id=
"instance_method_details" class=
"method_details_list">
201 <h2>Instance Method Details
</h2>
204 <div class=
"method_details first">
205 <h3 class=
"signature first" id=
"camelize-instance_method">
207 - (
<tt>String
</tt>)
<strong>camelize
</strong>(str)
213 </h3><div class=
"docstring">
214 <div class=
"discussion">
216 Transforms a string from snake_case to UpperCamelCase
223 <p class=
"tag_title">Parameters:
</p>
228 <span class='name'
>str
</span>
231 <span class='type'
>(
<tt>String
</tt>)
</span>
236 <div class='inline'
><p>
237 the string that will be Camelized
245 <p class=
"tag_title">Returns:
</p>
251 <span class='type'
>(
<tt>String
</tt>)
</span>
256 <div class='inline'
><p>
257 the Camelized string.
265 </div><table class=
"source_code">
276 <pre class=
"code"><span class=
"info file"># File 'lib/lyricli/util.rb', line
9</span>
278 <span class='kw'
>def
</span> <span class='id identifier rubyid_camelize'
>camelize
</span><span class='lparen'
>(
</span><span class='id identifier rubyid_str'
>str
</span><span class='rparen'
>)
</span>
279 <span class='id identifier rubyid_str'
>str
</span><span class='period'
>.
</span><span class='id identifier rubyid_split'
>split
</span><span class='lparen'
>(
</span><span class='tstring'
><span class='tstring_beg'
>'
</span><span class='tstring_content'
>_
</span><span class='tstring_end'
>'
</span></span><span class='rparen'
>)
</span><span class='period'
>.
</span><span class='id identifier rubyid_map'
>map
</span> <span class='lbrace'
>{
</span><span class='op'
>|
</span><span class='id identifier rubyid_w'
>w
</span><span class='op'
>|
</span> <span class='id identifier rubyid_w'
>w
</span><span class='period'
>.
</span><span class='id identifier rubyid_capitalize'
>capitalize
</span><span class='rbrace'
>}
</span><span class='period'
>.
</span><span class='id identifier rubyid_join'
>join
</span>
280 <span class='kw'
>end
</span></pre>
286 <div class=
"method_details ">
287 <h3 class=
"signature " id=
"parse_class-instance_method">
289 - (
<tt>Class
</tt><sup>?
</sup>)
<strong>parse_class
</strong>(class_name)
295 </h3><div class=
"docstring">
296 <div class=
"discussion">
298 Takes a class name in snake_case and attempts to find the corresponding
299 class from the sources.
306 <p class=
"tag_title">Parameters:
</p>
311 <span class='name'
>class_name
</span>
314 <span class='type'
>(
<tt>String
</tt>)
</span>
319 <div class='inline'
><p>
320 the snake_case name of the class to search for.
328 <p class=
"tag_title">Returns:
</p>
334 <span class='type'
>(
<tt>Class
</tt>,
<tt>nil
</tt>)
</span>
339 <div class='inline'
><p>
340 the found class or nil
348 </div><table class=
"source_code">
364 <pre class=
"code"><span class=
"info file"># File 'lib/lyricli/util.rb', line
18</span>
366 <span class='kw'
>def
</span> <span class='id identifier rubyid_parse_class'
>parse_class
</span><span class='lparen'
>(
</span><span class='id identifier rubyid_class_name'
>class_name
</span><span class='rparen'
>)
</span>
367 <span class='kw'
>begin
</span>
368 <span class='id identifier rubyid_path'
>path
</span> <span class='op'
>=
</span> <span class='tstring'
><span class='tstring_beg'
>"</span><span class='tstring_content'
>Sources::
</span><span class='embexpr_beg'
>#{
</span><span class='id identifier rubyid_class_name'
>class_name
</span><span class='rbrace'
>}
</span><span class='tstring_end'
>"</span></span>
369 <span class='kw'
>return
</span> <span class='id identifier rubyid_eval'
>eval
</span><span class='lparen'
>(
</span><span class='id identifier rubyid_path'
>path
</span><span class='rparen'
>)
</span>
370 <span class='kw'
>rescue
</span> <span class='const'
>NameError
</span>
371 <span class='kw'
>return
</span> <span class='kw'
>nil
</span>
372 <span class='kw'
>end
</span>
373 <span class='kw'
>end
</span></pre>
379 <div class=
"method_details ">
380 <h3 class=
"signature " id=
"sanitize_param-instance_method">
382 - (
<tt>String
</tt>)
<strong>sanitize_param
</strong>(p)
388 </h3><div class=
"docstring">
389 <div class=
"discussion">
391 Simply escapes a param and substitutes spaces and escaped plus signs for
399 <p class=
"tag_title">Parameters:
</p>
404 <span class='name'
>p
</span>
407 <span class='type'
>(
<tt>String
</tt>)
</span>
412 <div class='inline'
><p>
413 the parameter to be sanitized
421 <p class=
"tag_title">Returns:
</p>
427 <span class='type'
>(
<tt>String
</tt>)
</span>
432 <div class='inline'
><p>
433 the sanitized parameter
441 </div><table class=
"source_code">
452 <pre class=
"code"><span class=
"info file"># File 'lib/lyricli/util.rb', line
32</span>
454 <span class='kw'
>def
</span> <span class='id identifier rubyid_sanitize_param'
>sanitize_param
</span><span class='lparen'
>(
</span><span class='id identifier rubyid_p'
>p
</span><span class='rparen'
>)
</span>
455 <span class='const'
>URI
</span><span class='period'
>.
</span><span class='id identifier rubyid_encode_www_form_component'
>encode_www_form_component
</span><span class='lparen'
>(
</span><span class='id identifier rubyid_p'
>p
</span><span class='period'
>.
</span><span class='id identifier rubyid_gsub'
>gsub
</span><span class='lparen'
>(
</span><span class='tstring'
><span class='regexp_beg'
>/
</span><span class='tstring_content'
> </span><span class='regexp_end'
>/
</span></span><span class='comma'
>,
</span> <span class='tstring'
><span class='tstring_beg'
>"</span><span class='tstring_content'
>+
</span><span class='tstring_end'
>"</span></span><span class='rparen'
>)
</span><span class='rparen'
>)
</span><span class='period'
>.
</span><span class='id identifier rubyid_gsub'
>gsub
</span><span class='lparen'
>(
</span><span class='tstring'
><span class='tstring_beg'
>"</span><span class='tstring_content'
>%
2B
</span><span class='tstring_end'
>"</span></span><span class='comma'
>,
</span> <span class='tstring'
><span class='tstring_beg'
>"</span><span class='tstring_content'
>+
</span><span class='tstring_end'
>"</span></span><span class='rparen'
>)
</span>
456 <span class='kw'
>end
</span></pre>
467 Generated on Sat Oct
6 02:
34:
27 2012 by
468 <a href=
"http://yardoc.org" title=
"Yay! A Ruby Documentation Tool" target=
"_parent">yard
</a>
469 0.8.2.1 (ruby-
1.9.2).