mack-facets 0.7.1 → 0.7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- metadata +2 -47
- data/doc/classes/Array.html +0 -408
- data/doc/classes/Class.html +0 -233
- data/doc/classes/Hash.html +0 -233
- data/doc/classes/Kernel.html +0 -212
- data/doc/classes/Mack/Facets/DateTime.html +0 -168
- data/doc/classes/Mack/Facets.html +0 -111
- data/doc/classes/Mack/Utils/BlankSlate.html +0 -113
- data/doc/classes/Mack/Utils/Inflector.html +0 -382
- data/doc/classes/Mack/Utils/RegistryList.html +0 -469
- data/doc/classes/Mack/Utils/RegistryMap.html +0 -479
- data/doc/classes/Math.html +0 -188
- data/doc/classes/Module.html +0 -203
- data/doc/classes/NilClass.html +0 -148
- data/doc/classes/Object.html +0 -558
- data/doc/classes/String.html +0 -464
- data/doc/classes/Symbol.html +0 -148
- data/doc/classes/Time.html +0 -204
- data/doc/created.rid +0 -1
- data/doc/files/README.html +0 -112
- data/doc/files/lib/mack-facets/english_extensions/inflect_rb.html +0 -101
- data/doc/files/lib/mack-facets/english_extensions/numerals_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/array_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/class_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/date_time_rb.html +0 -129
- data/doc/files/lib/mack-facets/extensions/hash_rb.html +0 -108
- data/doc/files/lib/mack-facets/extensions/kernel_rb.html +0 -109
- data/doc/files/lib/mack-facets/extensions/math_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/module_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/nil_class_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/object_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/string_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/symbol_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/time_rb.html +0 -108
- data/doc/files/lib/mack-facets/utils/blank_slate_rb.html +0 -101
- data/doc/files/lib/mack-facets/utils/inflections_rb.html +0 -101
- data/doc/files/lib/mack-facets/utils/inflector_rb.html +0 -108
- data/doc/files/lib/mack-facets/utils/options_merger_rb.html +0 -101
- data/doc/files/lib/mack-facets/utils/registry_list_rb.html +0 -108
- data/doc/files/lib/mack-facets/utils/registry_map_rb.html +0 -108
- data/doc/files/lib/mack-facets_rb.html +0 -124
- data/doc/fr_class_index.html +0 -43
- data/doc/fr_file_index.html +0 -48
- data/doc/fr_method_index.html +0 -104
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
data/doc/classes/String.html
DELETED
@@ -1,464 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: String</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">String</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../files/lib/mack-facets/extensions/string_rb.html">
|
59
|
-
lib/mack-facets/extensions/string.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
<a href="Object.html">
|
69
|
-
Object
|
70
|
-
</a>
|
71
|
-
</td>
|
72
|
-
</tr>
|
73
|
-
</table>
|
74
|
-
</div>
|
75
|
-
<!-- banner header -->
|
76
|
-
|
77
|
-
<div id="bodyContent">
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<div id="contextContent">
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
</div>
|
86
|
-
|
87
|
-
<div id="method-list">
|
88
|
-
<h3 class="section-bar">Methods</h3>
|
89
|
-
|
90
|
-
<div class="name-list">
|
91
|
-
<a href="#M000035">constantize</a>
|
92
|
-
<a href="#M000036">hexdigest</a>
|
93
|
-
<a href="#M000037">hexdigest!</a>
|
94
|
-
<a href="#M000034">methodize</a>
|
95
|
-
<a href="#M000038">randomize</a>
|
96
|
-
<a href="#M000041">truncate</a>
|
97
|
-
<a href="#M000042">truncate!</a>
|
98
|
-
<a href="#M000039">uri_escape</a>
|
99
|
-
<a href="#M000040">uri_unescape</a>
|
100
|
-
</div>
|
101
|
-
</div>
|
102
|
-
|
103
|
-
</div>
|
104
|
-
|
105
|
-
|
106
|
-
<!-- if includes -->
|
107
|
-
<div id="includes">
|
108
|
-
<h3 class="section-bar">Included Modules</h3>
|
109
|
-
|
110
|
-
<div id="includes-list">
|
111
|
-
<span class="include-name">Style</span>
|
112
|
-
</div>
|
113
|
-
</div>
|
114
|
-
|
115
|
-
<div id="section">
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
<div id="aliases-list">
|
120
|
-
<h3 class="section-bar">External Aliases</h3>
|
121
|
-
|
122
|
-
<div class="name-list">
|
123
|
-
<table summary="aliases">
|
124
|
-
<tr class="top-aligned-row context-row">
|
125
|
-
<td class="context-item-name">snakecase</td>
|
126
|
-
<td>-></td>
|
127
|
-
<td class="context-item-value">underscore</td>
|
128
|
-
</tr>
|
129
|
-
</table>
|
130
|
-
</div>
|
131
|
-
</div>
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
<!-- if method_list -->
|
138
|
-
<div id="methods">
|
139
|
-
<h3 class="section-bar">Public Class methods</h3>
|
140
|
-
|
141
|
-
<div id="method-M000038" class="method-detail">
|
142
|
-
<a name="M000038"></a>
|
143
|
-
|
144
|
-
<div class="method-heading">
|
145
|
-
<a href="#M000038" class="method-signature">
|
146
|
-
<span class="method-name">randomize</span><span class="method-args">(length = 10)</span>
|
147
|
-
</a>
|
148
|
-
</div>
|
149
|
-
|
150
|
-
<div class="method-description">
|
151
|
-
<p><a class="source-toggle" href="#"
|
152
|
-
onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
|
153
|
-
<div class="method-source-code" id="M000038-source">
|
154
|
-
<pre>
|
155
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/string.rb, line 97</span>
|
156
|
-
97: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">randomize</span>(<span class="ruby-identifier">length</span> = <span class="ruby-value">10</span>)
|
157
|
-
98: <span class="ruby-identifier">chars</span> = (<span class="ruby-value str">"A"</span><span class="ruby-operator">..</span><span class="ruby-value str">"H"</span>).<span class="ruby-identifier">to_a</span> <span class="ruby-operator">+</span> (<span class="ruby-value str">"J"</span><span class="ruby-operator">..</span><span class="ruby-value str">"N"</span>).<span class="ruby-identifier">to_a</span> <span class="ruby-operator">+</span> (<span class="ruby-value str">"P"</span><span class="ruby-operator">..</span><span class="ruby-value str">"T"</span>).<span class="ruby-identifier">to_a</span> <span class="ruby-operator">+</span> (<span class="ruby-value str">"W"</span><span class="ruby-operator">..</span><span class="ruby-value str">"Z"</span>).<span class="ruby-identifier">to_a</span> <span class="ruby-operator">+</span> (<span class="ruby-value str">"3"</span><span class="ruby-operator">..</span><span class="ruby-value str">"9"</span>).<span class="ruby-identifier">to_a</span>
|
158
|
-
99: <span class="ruby-identifier">newpass</span> = <span class="ruby-value str">""</span>
|
159
|
-
100: <span class="ruby-value">1</span>.<span class="ruby-identifier">upto</span>(<span class="ruby-identifier">length</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">newpass</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">chars</span>[<span class="ruby-identifier">rand</span>(<span class="ruby-identifier">chars</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>)] }
|
160
|
-
101: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">newpass</span>.<span class="ruby-identifier">upcase</span>
|
161
|
-
102: <span class="ruby-keyword kw">end</span>
|
162
|
-
</pre>
|
163
|
-
</div>
|
164
|
-
</div>
|
165
|
-
</div>
|
166
|
-
|
167
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
168
|
-
|
169
|
-
<div id="method-M000035" class="method-detail">
|
170
|
-
<a name="M000035"></a>
|
171
|
-
|
172
|
-
<div class="method-heading">
|
173
|
-
<a href="#M000035" class="method-signature">
|
174
|
-
<span class="method-name">constantize</span><span class="method-args">()</span>
|
175
|
-
</a>
|
176
|
-
</div>
|
177
|
-
|
178
|
-
<div class="method-description">
|
179
|
-
<p>
|
180
|
-
Returns a constant of the string.
|
181
|
-
</p>
|
182
|
-
<p>
|
183
|
-
Examples:
|
184
|
-
</p>
|
185
|
-
<pre>
|
186
|
-
"User".constantize # => User
|
187
|
-
"HomeController".constantize # => HomeController
|
188
|
-
"Mack::Configuration" # => Mack::Configuration
|
189
|
-
</pre>
|
190
|
-
<p><a class="source-toggle" href="#"
|
191
|
-
onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
|
192
|
-
<div class="method-source-code" id="M000035-source">
|
193
|
-
<pre>
|
194
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/string.rb, line 85</span>
|
195
|
-
85: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">constantize</span>
|
196
|
-
86: <span class="ruby-constant">Module</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-node">"::#{self}"</span>)
|
197
|
-
87: <span class="ruby-keyword kw">end</span>
|
198
|
-
</pre>
|
199
|
-
</div>
|
200
|
-
</div>
|
201
|
-
</div>
|
202
|
-
|
203
|
-
<div id="method-M000036" class="method-detail">
|
204
|
-
<a name="M000036"></a>
|
205
|
-
|
206
|
-
<div class="method-heading">
|
207
|
-
<a href="#M000036" class="method-signature">
|
208
|
-
<span class="method-name">hexdigest</span><span class="method-args">()</span>
|
209
|
-
</a>
|
210
|
-
</div>
|
211
|
-
|
212
|
-
<div class="method-description">
|
213
|
-
<p><a class="source-toggle" href="#"
|
214
|
-
onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
|
215
|
-
<div class="method-source-code" id="M000036-source">
|
216
|
-
<pre>
|
217
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/string.rb, line 89</span>
|
218
|
-
89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hexdigest</span>
|
219
|
-
90: <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">SHA1</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-keyword kw">self</span>)
|
220
|
-
91: <span class="ruby-keyword kw">end</span>
|
221
|
-
</pre>
|
222
|
-
</div>
|
223
|
-
</div>
|
224
|
-
</div>
|
225
|
-
|
226
|
-
<div id="method-M000037" class="method-detail">
|
227
|
-
<a name="M000037"></a>
|
228
|
-
|
229
|
-
<div class="method-heading">
|
230
|
-
<a href="#M000037" class="method-signature">
|
231
|
-
<span class="method-name">hexdigest!</span><span class="method-args">()</span>
|
232
|
-
</a>
|
233
|
-
</div>
|
234
|
-
|
235
|
-
<div class="method-description">
|
236
|
-
<p><a class="source-toggle" href="#"
|
237
|
-
onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
|
238
|
-
<div class="method-source-code" id="M000037-source">
|
239
|
-
<pre>
|
240
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/string.rb, line 93</span>
|
241
|
-
93: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hexdigest!</span>
|
242
|
-
94: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">hexdigest</span>)
|
243
|
-
95: <span class="ruby-keyword kw">end</span>
|
244
|
-
</pre>
|
245
|
-
</div>
|
246
|
-
</div>
|
247
|
-
</div>
|
248
|
-
|
249
|
-
<div id="method-M000034" class="method-detail">
|
250
|
-
<a name="M000034"></a>
|
251
|
-
|
252
|
-
<div class="method-heading">
|
253
|
-
<a href="#M000034" class="method-signature">
|
254
|
-
<span class="method-name">methodize</span><span class="method-args">()</span>
|
255
|
-
</a>
|
256
|
-
</div>
|
257
|
-
|
258
|
-
<div class="method-description">
|
259
|
-
<p><a class="source-toggle" href="#"
|
260
|
-
onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
|
261
|
-
<div class="method-source-code" id="M000034-source">
|
262
|
-
<pre>
|
263
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/string.rb, line 6</span>
|
264
|
-
6: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">methodize</span>
|
265
|
-
7: <span class="ruby-identifier">x</span> = <span class="ruby-keyword kw">self</span>
|
266
|
-
8:
|
267
|
-
9: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
|
268
|
-
10: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{self} cannot be converted to a valid method name!"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span>
|
269
|
-
11:
|
270
|
-
12: <span class="ruby-comment cmt"># get rid of the big stuff in the front/back</span>
|
271
|
-
13: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">strip!</span>
|
272
|
-
14:
|
273
|
-
15: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
|
274
|
-
16: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{self} cannot be converted to a valid method name!"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span>
|
275
|
-
17:
|
276
|
-
18: <span class="ruby-identifier">x</span> = <span class="ruby-identifier">x</span>.<span class="ruby-identifier">underscore</span>
|
277
|
-
19:
|
278
|
-
20: <span class="ruby-comment cmt"># get rid of spaces and make the _</span>
|
279
|
-
21: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">' '</span>, <span class="ruby-value str">'_'</span>)
|
280
|
-
22: <span class="ruby-comment cmt"># get rid of everything that isn't 'safe' a-z, 0-9, ?, !, =, _</span>
|
281
|
-
23: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/([^ a-zA-Z0-9\_\?\!\=]+)/n</span>, <span class="ruby-value str">'_'</span>)
|
282
|
-
24:
|
283
|
-
25: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
|
284
|
-
26: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{self} cannot be converted to a valid method name!"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span>
|
285
|
-
27:
|
286
|
-
28: <span class="ruby-comment cmt"># condense multiple 'safe' non a-z chars to just one.</span>
|
287
|
-
29: <span class="ruby-comment cmt"># ie. ___ becomes _ !!!! becomes ! etc...</span>
|
288
|
-
30: [<span class="ruby-value str">' '</span>, <span class="ruby-value str">'_'</span>, <span class="ruby-value str">'?'</span>, <span class="ruby-value str">'!'</span>, <span class="ruby-value str">"="</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
|
289
|
-
31: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">squeeze!</span>(<span class="ruby-identifier">c</span>)
|
290
|
-
32: <span class="ruby-keyword kw">end</span>
|
291
|
-
33:
|
292
|
-
34: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
|
293
|
-
35: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{self} cannot be converted to a valid method name!"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span>
|
294
|
-
36:
|
295
|
-
37: <span class="ruby-comment cmt">#down case the whole thing</span>
|
296
|
-
38: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">downcase!</span>
|
297
|
-
39:
|
298
|
-
40: <span class="ruby-comment cmt"># get rid of any characters at the beginning that aren't a-z</span>
|
299
|
-
41: <span class="ruby-keyword kw">while</span> <span class="ruby-operator">!</span><span class="ruby-identifier">x</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/^[a-z]/</span>)
|
300
|
-
42: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">0</span>)
|
301
|
-
43:
|
302
|
-
44: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
|
303
|
-
45: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{self} cannot be converted to a valid method name!"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span>
|
304
|
-
46: <span class="ruby-keyword kw">end</span>
|
305
|
-
47:
|
306
|
-
48: <span class="ruby-comment cmt"># let's trim this bad boy down a bit now that we've cleaned it up, somewhat.</span>
|
307
|
-
49: <span class="ruby-comment cmt"># we should do this before cleaning up the end character, because it's possible to end up with a </span>
|
308
|
-
50: <span class="ruby-comment cmt"># bad char at the end if you trim too late.</span>
|
309
|
-
51: <span class="ruby-identifier">x</span> = <span class="ruby-identifier">x</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">100</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">100</span>
|
310
|
-
52:
|
311
|
-
53: <span class="ruby-comment cmt"># get rid of any characters at the end that aren't safe</span>
|
312
|
-
54: <span class="ruby-keyword kw">while</span> <span class="ruby-operator">!</span><span class="ruby-identifier">x</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/[a-z0-9\?\!\=]$/</span>)
|
313
|
-
55: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-identifier">x</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)
|
314
|
-
56: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
|
315
|
-
57: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{self} cannot be converted to a valid method name!"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span>
|
316
|
-
58: <span class="ruby-keyword kw">end</span>
|
317
|
-
59:
|
318
|
-
60: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
|
319
|
-
61: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{self} cannot be converted to a valid method name!"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span>
|
320
|
-
62:
|
321
|
-
63: <span class="ruby-comment cmt"># let's get rid of characters that don't belong in the 'middle' of the method.</span>
|
322
|
-
64: <span class="ruby-identifier">orig_middle</span> = <span class="ruby-identifier">x</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span>(<span class="ruby-identifier">x</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span>)]
|
323
|
-
65: <span class="ruby-identifier">n_middle</span> = <span class="ruby-identifier">orig_middle</span>.<span class="ruby-identifier">dup</span>
|
324
|
-
66:
|
325
|
-
67: [<span class="ruby-value str">'?'</span>, <span class="ruby-value str">'!'</span>, <span class="ruby-value str">"="</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
|
326
|
-
68: <span class="ruby-identifier">n_middle</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">c</span>, <span class="ruby-value str">"_"</span>)
|
327
|
-
69: <span class="ruby-keyword kw">end</span>
|
328
|
-
70:
|
329
|
-
71: <span class="ruby-comment cmt"># the previous gsub can leave us with multiple underscores that need cleaning up.</span>
|
330
|
-
72: <span class="ruby-identifier">n_middle</span>.<span class="ruby-identifier">squeeze!</span>(<span class="ruby-value str">"_"</span>)
|
331
|
-
73:
|
332
|
-
74: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">orig_middle</span>, <span class="ruby-identifier">n_middle</span>)
|
333
|
-
75: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">"_="</span>, <span class="ruby-value str">"="</span>)
|
334
|
-
76: <span class="ruby-identifier">x</span>
|
335
|
-
77: <span class="ruby-keyword kw">end</span>
|
336
|
-
</pre>
|
337
|
-
</div>
|
338
|
-
</div>
|
339
|
-
</div>
|
340
|
-
|
341
|
-
<div id="method-M000041" class="method-detail">
|
342
|
-
<a name="M000041"></a>
|
343
|
-
|
344
|
-
<div class="method-heading">
|
345
|
-
<a href="#M000041" class="method-signature">
|
346
|
-
<span class="method-name">truncate</span><span class="method-args">(length = 30, truncate_string = "...")</span>
|
347
|
-
</a>
|
348
|
-
</div>
|
349
|
-
|
350
|
-
<div class="method-description">
|
351
|
-
<p><a class="source-toggle" href="#"
|
352
|
-
onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
|
353
|
-
<div class="method-source-code" id="M000041-source">
|
354
|
-
<pre>
|
355
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/string.rb, line 120</span>
|
356
|
-
120: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">truncate</span>(<span class="ruby-identifier">length</span> = <span class="ruby-value">30</span>, <span class="ruby-identifier">truncate_string</span> = <span class="ruby-value str">"..."</span>)
|
357
|
-
121: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">then</span> <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">end</span>
|
358
|
-
122: <span class="ruby-identifier">l</span> = <span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">truncate_string</span>.<span class="ruby-identifier">length</span>
|
359
|
-
123: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$KCODE</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"NONE"</span>
|
360
|
-
124: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-identifier">length</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">self</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">l</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">truncate_string</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>
|
361
|
-
125: <span class="ruby-keyword kw">else</span>
|
362
|
-
126: <span class="ruby-identifier">chars</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">//</span>)
|
363
|
-
127: <span class="ruby-identifier">chars</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-identifier">length</span> <span class="ruby-value">? </span><span class="ruby-identifier">chars</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">l</span>].<span class="ruby-identifier">join</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">truncate_string</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>
|
364
|
-
128: <span class="ruby-keyword kw">end</span>
|
365
|
-
129: <span class="ruby-keyword kw">end</span>
|
366
|
-
</pre>
|
367
|
-
</div>
|
368
|
-
</div>
|
369
|
-
</div>
|
370
|
-
|
371
|
-
<div id="method-M000042" class="method-detail">
|
372
|
-
<a name="M000042"></a>
|
373
|
-
|
374
|
-
<div class="method-heading">
|
375
|
-
<a href="#M000042" class="method-signature">
|
376
|
-
<span class="method-name">truncate!</span><span class="method-args">(length = 30, truncate_string = "...")</span>
|
377
|
-
</a>
|
378
|
-
</div>
|
379
|
-
|
380
|
-
<div class="method-description">
|
381
|
-
<p><a class="source-toggle" href="#"
|
382
|
-
onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
|
383
|
-
<div class="method-source-code" id="M000042-source">
|
384
|
-
<pre>
|
385
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/string.rb, line 131</span>
|
386
|
-
131: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">truncate!</span>(<span class="ruby-identifier">length</span> = <span class="ruby-value">30</span>, <span class="ruby-identifier">truncate_string</span> = <span class="ruby-value str">"..."</span>)
|
387
|
-
132: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">truncate</span>(<span class="ruby-identifier">length</span>, <span class="ruby-identifier">truncate_string</span>))
|
388
|
-
133: <span class="ruby-keyword kw">end</span>
|
389
|
-
</pre>
|
390
|
-
</div>
|
391
|
-
</div>
|
392
|
-
</div>
|
393
|
-
|
394
|
-
<div id="method-M000039" class="method-detail">
|
395
|
-
<a name="M000039"></a>
|
396
|
-
|
397
|
-
<div class="method-heading">
|
398
|
-
<a href="#M000039" class="method-signature">
|
399
|
-
<span class="method-name">uri_escape</span><span class="method-args">()</span>
|
400
|
-
</a>
|
401
|
-
</div>
|
402
|
-
|
403
|
-
<div class="method-description">
|
404
|
-
<p>
|
405
|
-
Performs URI escaping so that you can construct proper query strings
|
406
|
-
faster. Use this rather than the cgi.rb version since it‘s faster.
|
407
|
-
(Stolen from Camping).
|
408
|
-
</p>
|
409
|
-
<p><a class="source-toggle" href="#"
|
410
|
-
onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
|
411
|
-
<div class="method-source-code" id="M000039-source">
|
412
|
-
<pre>
|
413
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/string.rb, line 107</span>
|
414
|
-
107: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uri_escape</span>
|
415
|
-
108: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/([^ a-zA-Z0-9_.-]+)/n</span>) {
|
416
|
-
109: <span class="ruby-value str">'%'</span><span class="ruby-operator">+</span><span class="ruby-identifier">$1</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">'H2'</span><span class="ruby-operator">*</span><span class="ruby-identifier">$1</span>.<span class="ruby-identifier">size</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">'%'</span>).<span class="ruby-identifier">upcase</span>
|
417
|
-
110: }.<span class="ruby-identifier">tr</span>(<span class="ruby-value str">' '</span>, <span class="ruby-value str">'+'</span>)
|
418
|
-
111: <span class="ruby-keyword kw">end</span>
|
419
|
-
</pre>
|
420
|
-
</div>
|
421
|
-
</div>
|
422
|
-
</div>
|
423
|
-
|
424
|
-
<div id="method-M000040" class="method-detail">
|
425
|
-
<a name="M000040"></a>
|
426
|
-
|
427
|
-
<div class="method-heading">
|
428
|
-
<a href="#M000040" class="method-signature">
|
429
|
-
<span class="method-name">uri_unescape</span><span class="method-args">()</span>
|
430
|
-
</a>
|
431
|
-
</div>
|
432
|
-
|
433
|
-
<div class="method-description">
|
434
|
-
<p>
|
435
|
-
Unescapes a URI escaped string. (Stolen from Camping).
|
436
|
-
</p>
|
437
|
-
<p><a class="source-toggle" href="#"
|
438
|
-
onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
|
439
|
-
<div class="method-source-code" id="M000040-source">
|
440
|
-
<pre>
|
441
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/string.rb, line 114</span>
|
442
|
-
114: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uri_unescape</span>
|
443
|
-
115: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">tr</span>(<span class="ruby-value str">'+'</span>, <span class="ruby-value str">' '</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/((?:%[0-9a-fA-F]{2})+)/n</span>){
|
444
|
-
116: [<span class="ruby-identifier">$1</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">'%'</span>)].<span class="ruby-identifier">pack</span>(<span class="ruby-value str">'H*'</span>)
|
445
|
-
117: }
|
446
|
-
118: <span class="ruby-keyword kw">end</span>
|
447
|
-
</pre>
|
448
|
-
</div>
|
449
|
-
</div>
|
450
|
-
</div>
|
451
|
-
|
452
|
-
|
453
|
-
</div>
|
454
|
-
|
455
|
-
|
456
|
-
</div>
|
457
|
-
|
458
|
-
|
459
|
-
<div id="validator-badges">
|
460
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
461
|
-
</div>
|
462
|
-
|
463
|
-
</body>
|
464
|
-
</html>
|
data/doc/classes/Symbol.html
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: Symbol</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Symbol</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../files/lib/mack-facets/extensions/symbol_rb.html">
|
59
|
-
lib/mack-facets/extensions/symbol.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
<a href="Object.html">
|
69
|
-
Object
|
70
|
-
</a>
|
71
|
-
</td>
|
72
|
-
</tr>
|
73
|
-
</table>
|
74
|
-
</div>
|
75
|
-
<!-- banner header -->
|
76
|
-
|
77
|
-
<div id="bodyContent">
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<div id="contextContent">
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
</div>
|
86
|
-
|
87
|
-
<div id="method-list">
|
88
|
-
<h3 class="section-bar">Methods</h3>
|
89
|
-
|
90
|
-
<div class="name-list">
|
91
|
-
<a href="#M000026">methodize</a>
|
92
|
-
</div>
|
93
|
-
</div>
|
94
|
-
|
95
|
-
</div>
|
96
|
-
|
97
|
-
|
98
|
-
<!-- if includes -->
|
99
|
-
|
100
|
-
<div id="section">
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
<!-- if method_list -->
|
110
|
-
<div id="methods">
|
111
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
112
|
-
|
113
|
-
<div id="method-M000026" class="method-detail">
|
114
|
-
<a name="M000026"></a>
|
115
|
-
|
116
|
-
<div class="method-heading">
|
117
|
-
<a href="#M000026" class="method-signature">
|
118
|
-
<span class="method-name">methodize</span><span class="method-args">()</span>
|
119
|
-
</a>
|
120
|
-
</div>
|
121
|
-
|
122
|
-
<div class="method-description">
|
123
|
-
<p><a class="source-toggle" href="#"
|
124
|
-
onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
|
125
|
-
<div class="method-source-code" id="M000026-source">
|
126
|
-
<pre>
|
127
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/symbol.rb, line 3</span>
|
128
|
-
3: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">methodize</span>
|
129
|
-
4: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">methodize</span>
|
130
|
-
5: <span class="ruby-keyword kw">end</span>
|
131
|
-
</pre>
|
132
|
-
</div>
|
133
|
-
</div>
|
134
|
-
</div>
|
135
|
-
|
136
|
-
|
137
|
-
</div>
|
138
|
-
|
139
|
-
|
140
|
-
</div>
|
141
|
-
|
142
|
-
|
143
|
-
<div id="validator-badges">
|
144
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
145
|
-
</div>
|
146
|
-
|
147
|
-
</body>
|
148
|
-
</html>
|