mack_ruby_core_extensions 0.1.22 → 0.1.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/lib/extensions/hash.rb +13 -0
  2. data/lib/utils/inflections.rb +2 -1
  3. data/test/extensions/hash_test.rb +14 -0
  4. metadata +3 -38
  5. data/doc/classes/Array.html +0 -465
  6. data/doc/classes/Class.html +0 -233
  7. data/doc/classes/Float.html +0 -148
  8. data/doc/classes/Hash.html +0 -233
  9. data/doc/classes/Kernel.html +0 -184
  10. data/doc/classes/Mack/Utils/Inflector.html +0 -422
  11. data/doc/classes/Math.html +0 -188
  12. data/doc/classes/MethodNotImplemented.html +0 -155
  13. data/doc/classes/Module.html +0 -203
  14. data/doc/classes/NilClass.html +0 -151
  15. data/doc/classes/Object.html +0 -448
  16. data/doc/classes/String.html +0 -977
  17. data/doc/classes/Symbol.html +0 -148
  18. data/doc/created.rid +0 -1
  19. data/doc/files/README.html +0 -151
  20. data/doc/files/lib/extensions/array_rb.html +0 -101
  21. data/doc/files/lib/extensions/class_rb.html +0 -101
  22. data/doc/files/lib/extensions/float_rb.html +0 -101
  23. data/doc/files/lib/extensions/hash_rb.html +0 -108
  24. data/doc/files/lib/extensions/kernel_rb.html +0 -109
  25. data/doc/files/lib/extensions/math_rb.html +0 -101
  26. data/doc/files/lib/extensions/method_not_implemented_rb.html +0 -108
  27. data/doc/files/lib/extensions/module_rb.html +0 -101
  28. data/doc/files/lib/extensions/nil_rb.html +0 -101
  29. data/doc/files/lib/extensions/object_rb.html +0 -101
  30. data/doc/files/lib/extensions/string_rb.html +0 -108
  31. data/doc/files/lib/extensions/symbol_rb.html +0 -101
  32. data/doc/files/lib/mack_ruby_core_extensions_rb.html +0 -101
  33. data/doc/files/lib/utils/inflections_rb.html +0 -101
  34. data/doc/files/lib/utils/inflector_rb.html +0 -108
  35. data/doc/fr_class_index.html +0 -39
  36. data/doc/fr_file_index.html +0 -42
  37. data/doc/fr_method_index.html +0 -96
  38. data/doc/index.html +0 -24
  39. data/doc/rdoc-style.css +0 -208
@@ -1,977 +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/extensions/string_rb.html">
59
- lib/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">blank?</a>&nbsp;&nbsp;
92
- <a href="#M000046">breakify</a>&nbsp;&nbsp;
93
- <a href="#M000047">breakify!</a>&nbsp;&nbsp;
94
- <a href="#M000033">camelcase</a>&nbsp;&nbsp;
95
- <a href="#M000053">capitalize_all_words</a>&nbsp;&nbsp;
96
- <a href="#M000054">capitalize_all_words!</a>&nbsp;&nbsp;
97
- <a href="#M000034">constantize</a>&nbsp;&nbsp;
98
- <a href="#M000042">ends_with?</a>&nbsp;&nbsp;
99
- <a href="#M000048">hexdigest</a>&nbsp;&nbsp;
100
- <a href="#M000049">hexdigest!</a>&nbsp;&nbsp;
101
- <a href="#M000038">linkify</a>&nbsp;&nbsp;
102
- <a href="#M000039">methodize</a>&nbsp;&nbsp;
103
- <a href="#M000036">plural</a>&nbsp;&nbsp;
104
- <a href="#M000043">pluralize_word</a>&nbsp;&nbsp;
105
- <a href="#M000050">randomize</a>&nbsp;&nbsp;
106
- <a href="#M000044">remove</a>&nbsp;&nbsp;
107
- <a href="#M000045">remove!</a>&nbsp;&nbsp;
108
- <a href="#M000037">singular</a>&nbsp;&nbsp;
109
- <a href="#M000055">sql_safe_str</a>&nbsp;&nbsp;
110
- <a href="#M000056">sql_safe_str!</a>&nbsp;&nbsp;
111
- <a href="#M000041">starts_with?</a>&nbsp;&nbsp;
112
- <a href="#M000032">to_instance</a>&nbsp;&nbsp;
113
- <a href="#M000051">truncate</a>&nbsp;&nbsp;
114
- <a href="#M000052">truncate!</a>&nbsp;&nbsp;
115
- <a href="#M000040">underscore</a>&nbsp;&nbsp;
116
- <a href="#M000057">uri_escape</a>&nbsp;&nbsp;
117
- <a href="#M000058">uri_unescape</a>&nbsp;&nbsp;
118
- </div>
119
- </div>
120
-
121
- </div>
122
-
123
-
124
- <!-- if includes -->
125
-
126
- <div id="section">
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
- <!-- if method_list -->
136
- <div id="methods">
137
- <h3 class="section-bar">Public Class methods</h3>
138
-
139
- <div id="method-M000043" class="method-detail">
140
- <a name="M000043"></a>
141
-
142
- <div class="method-heading">
143
- <a href="#M000043" class="method-signature">
144
- <span class="method-name">pluralize_word</span><span class="method-args">(num, vals = [&quot;is&quot;, &quot;are&quot;])</span>
145
- </a>
146
- </div>
147
-
148
- <div class="method-description">
149
- <p>
150
- Returns &quot;is&quot; or &quot;are&quot; based on the number, i.e.
151
- &quot;i=6; There #{isare(i)} #{i} topics here.&quot;
152
- </p>
153
- <p><a class="source-toggle" href="#"
154
- onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
155
- <div class="method-source-code" id="M000043-source">
156
- <pre>
157
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 170</span>
158
- 170: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">pluralize_word</span>(<span class="ruby-identifier">num</span>, <span class="ruby-identifier">vals</span> = [<span class="ruby-value str">&quot;is&quot;</span>, <span class="ruby-value str">&quot;are&quot;</span>])
159
- 171: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">vals</span>[<span class="ruby-value">0</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">num</span>.<span class="ruby-identifier">to_i</span><span class="ruby-operator">==</span><span class="ruby-value">1</span>
160
- 172: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">vals</span>[<span class="ruby-value">1</span>]
161
- 173: <span class="ruby-keyword kw">end</span>
162
- </pre>
163
- </div>
164
- </div>
165
- </div>
166
-
167
- <div id="method-M000050" class="method-detail">
168
- <a name="M000050"></a>
169
-
170
- <div class="method-heading">
171
- <a href="#M000050" class="method-signature">
172
- <span class="method-name">randomize</span><span class="method-args">(length = 10)</span>
173
- </a>
174
- </div>
175
-
176
- <div class="method-description">
177
- <p><a class="source-toggle" href="#"
178
- onclick="toggleCode('M000050-source');return false;">[Source]</a></p>
179
- <div class="method-source-code" id="M000050-source">
180
- <pre>
181
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 224</span>
182
- 224: <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>)
183
- 225: <span class="ruby-identifier">chars</span> = (<span class="ruby-value str">&quot;A&quot;</span><span class="ruby-operator">..</span><span class="ruby-value str">&quot;H&quot;</span>).<span class="ruby-identifier">to_a</span> <span class="ruby-operator">+</span> (<span class="ruby-value str">&quot;J&quot;</span><span class="ruby-operator">..</span><span class="ruby-value str">&quot;N&quot;</span>).<span class="ruby-identifier">to_a</span> <span class="ruby-operator">+</span> (<span class="ruby-value str">&quot;P&quot;</span><span class="ruby-operator">..</span><span class="ruby-value str">&quot;T&quot;</span>).<span class="ruby-identifier">to_a</span> <span class="ruby-operator">+</span> (<span class="ruby-value str">&quot;W&quot;</span><span class="ruby-operator">..</span><span class="ruby-value str">&quot;Z&quot;</span>).<span class="ruby-identifier">to_a</span> <span class="ruby-operator">+</span> (<span class="ruby-value str">&quot;3&quot;</span><span class="ruby-operator">..</span><span class="ruby-value str">&quot;9&quot;</span>).<span class="ruby-identifier">to_a</span>
184
- 226: <span class="ruby-identifier">newpass</span> = <span class="ruby-value str">&quot;&quot;</span>
185
- 227: <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">&lt;&lt;</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>)] }
186
- 228: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">newpass</span>.<span class="ruby-identifier">upcase</span>
187
- 229: <span class="ruby-keyword kw">end</span>
188
- </pre>
189
- </div>
190
- </div>
191
- </div>
192
-
193
- <h3 class="section-bar">Public Instance methods</h3>
194
-
195
- <div id="method-M000035" class="method-detail">
196
- <a name="M000035"></a>
197
-
198
- <div class="method-heading">
199
- <a href="#M000035" class="method-signature">
200
- <span class="method-name">blank?</span><span class="method-args">()</span>
201
- </a>
202
- </div>
203
-
204
- <div class="method-description">
205
- <p>
206
- If the string is empty, this will return true.
207
- </p>
208
- <p><a class="source-toggle" href="#"
209
- onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
210
- <div class="method-source-code" id="M000035-source">
211
- <pre>
212
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 30</span>
213
- 30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">blank?</span>
214
- 31: <span class="ruby-keyword kw">self</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
215
- 32: <span class="ruby-keyword kw">end</span>
216
- </pre>
217
- </div>
218
- </div>
219
- </div>
220
-
221
- <div id="method-M000046" class="method-detail">
222
- <a name="M000046"></a>
223
-
224
- <div class="method-heading">
225
- <a href="#M000046" class="method-signature">
226
- <span class="method-name">breakify</span><span class="method-args">(every = 30)</span>
227
- </a>
228
- </div>
229
-
230
- <div class="method-description">
231
- <p>
232
- makes long strings of unbroken characters wrap inside elements (hopefully!
233
- tested in Safari, Firefox, and IE for Windows) For documentation about this
234
- kind of workaround to this browser compatibility problem please see the
235
- following URL&#8216;s: <a
236
- href="http://www.quirksmode.org/oddsandends/wbr.html">www.quirksmode.org/oddsandends/wbr.html</a>
237
- <a
238
- href="http://krijnhoetmer.nl/stuff/css/word-wrap-break-word">krijnhoetmer.nl/stuff/css/word-wrap-break-word</a>/
239
- note: if the txt has spaces, this will only try to break up runs of
240
- non-space characters longer than &quot;every&quot; characters
241
- </p>
242
- <p><a class="source-toggle" href="#"
243
- onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
244
- <div class="method-source-code" id="M000046-source">
245
- <pre>
246
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 188</span>
247
- 188: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">breakify</span>(<span class="ruby-identifier">every</span> = <span class="ruby-value">30</span>)
248
- 189: <span class="ruby-identifier">every</span> = <span class="ruby-value">1</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">every</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">1</span>
249
- 190: <span class="ruby-identifier">text</span> = <span class="ruby-keyword kw">self</span>
250
- 191: <span class="ruby-identifier">textile_regex</span> = <span class="ruby-regexp re">/([^\&quot;]+\&quot;):([^:]*:[\/\/]{0,1}[^ ]*)/</span>
251
- 192: <span class="ruby-identifier">long_regex</span> = <span class="ruby-node">/\S{#{every},}/</span>
252
- 193: <span class="ruby-identifier">brokentxt</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">long_regex</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">longword</span><span class="ruby-operator">|</span>
253
- 194: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">longword</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">textile_regex</span> <span class="ruby-comment cmt">#if the longword is a textile link...ignore and recheck for the link text only</span>
254
- 195: <span class="ruby-identifier">textile_link</span> = <span class="ruby-identifier">textile_regex</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">longword</span>)[<span class="ruby-value">0</span>]
255
- 196: <span class="ruby-identifier">link_text</span> = <span class="ruby-identifier">textile_regex</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">longword</span>)[<span class="ruby-value">1</span>]
256
- 197: <span class="ruby-identifier">longword</span> = <span class="ruby-identifier">link_text</span>
257
- 198: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">longword</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">long_regex</span> <span class="ruby-comment cmt">#link text is long...allow break</span>
258
- 199: <span class="ruby-identifier">textile_link</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-node">/.{1,#{every}}/</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;&lt;wbr/&gt;&quot;</span>)
259
- 200: <span class="ruby-keyword kw">else</span>
260
- 201: <span class="ruby-identifier">textile_link</span> <span class="ruby-comment cmt">#the url is what triggered the match...so leave it alone</span>
261
- 202: <span class="ruby-keyword kw">end</span>
262
- 203: <span class="ruby-keyword kw">else</span>
263
- 204: <span class="ruby-identifier">longword</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-node">/.{1,#{every}}/</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;&lt;wbr/&gt;&quot;</span>) <span class="ruby-comment cmt">#no textile link matched</span>
264
- 205: <span class="ruby-keyword kw">end</span>
265
- 206: <span class="ruby-keyword kw">end</span>
266
- 207: <span class="ruby-comment cmt">#text = %Q[&lt;span style='word-wrap:break-word;wbr:after{content:&quot;\\00200B&quot;}'&gt;#{brokentxt}&lt;/span&gt;]</span>
267
- 208: <span class="ruby-comment cmt">#brokentxt.gsub(&quot;&lt;wbr/&gt;&quot;, &quot;&lt;br /&gt;&quot;)</span>
268
- 209: <span class="ruby-identifier">brokentxt</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">&quot;&lt;wbr/&gt;&quot;</span>, <span class="ruby-value str">&quot; &quot;</span>)
269
- 210: <span class="ruby-keyword kw">end</span>
270
- </pre>
271
- </div>
272
- </div>
273
- </div>
274
-
275
- <div id="method-M000047" class="method-detail">
276
- <a name="M000047"></a>
277
-
278
- <div class="method-heading">
279
- <a href="#M000047" class="method-signature">
280
- <span class="method-name">breakify!</span><span class="method-args">(every = 30)</span>
281
- </a>
282
- </div>
283
-
284
- <div class="method-description">
285
- <p><a class="source-toggle" href="#"
286
- onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
287
- <div class="method-source-code" id="M000047-source">
288
- <pre>
289
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 212</span>
290
- 212: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">breakify!</span>(<span class="ruby-identifier">every</span> = <span class="ruby-value">30</span>)
291
- 213: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">breakify</span>(<span class="ruby-identifier">every</span>))
292
- 214: <span class="ruby-keyword kw">end</span>
293
- </pre>
294
- </div>
295
- </div>
296
- </div>
297
-
298
- <div id="method-M000033" class="method-detail">
299
- <a name="M000033"></a>
300
-
301
- <div class="method-heading">
302
- <a href="#M000033" class="method-signature">
303
- <span class="method-name">camelcase</span><span class="method-args">()</span>
304
- </a>
305
- </div>
306
-
307
- <div class="method-description">
308
- <p>
309
- Camel cases the string.
310
- </p>
311
- <p>
312
- Examples:
313
- </p>
314
- <pre>
315
- &quot;user&quot;.camelcase # =&gt; User
316
- &quot;my_blog&quot;.camelcase # =&gt; MyBlog
317
- &quot;my/blog&quot;.camelcase # =&gt; My::Blog
318
- </pre>
319
- <p><a class="source-toggle" href="#"
320
- onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
321
- <div class="method-source-code" id="M000033-source">
322
- <pre>
323
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 15</span>
324
- 15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">camelcase</span>
325
- 16: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\/(.?)/</span>) { <span class="ruby-value str">&quot;::&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">$1</span>.<span class="ruby-identifier">upcase</span> }.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/(^|_)(.)/</span>) { <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">upcase</span> }
326
- 17: <span class="ruby-keyword kw">end</span>
327
- </pre>
328
- </div>
329
- </div>
330
- </div>
331
-
332
- <div id="method-M000053" class="method-detail">
333
- <a name="M000053"></a>
334
-
335
- <div class="method-heading">
336
- <a href="#M000053" class="method-signature">
337
- <span class="method-name">capitalize_all_words</span><span class="method-args">()</span>
338
- </a>
339
- </div>
340
-
341
- <div class="method-description">
342
- <p><a class="source-toggle" href="#"
343
- onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
344
- <div class="method-source-code" id="M000053-source">
345
- <pre>
346
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 246</span>
347
- 246: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">capitalize_all_words</span>
348
- 247: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\b\w/</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">upcase</span>}
349
- 248: <span class="ruby-keyword kw">end</span>
350
- </pre>
351
- </div>
352
- </div>
353
- </div>
354
-
355
- <div id="method-M000054" class="method-detail">
356
- <a name="M000054"></a>
357
-
358
- <div class="method-heading">
359
- <a href="#M000054" class="method-signature">
360
- <span class="method-name">capitalize_all_words!</span><span class="method-args">()</span>
361
- </a>
362
- </div>
363
-
364
- <div class="method-description">
365
- <p><a class="source-toggle" href="#"
366
- onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
367
- <div class="method-source-code" id="M000054-source">
368
- <pre>
369
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 250</span>
370
- 250: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">capitalize_all_words!</span>
371
- 251: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">capitalize_all_words</span>)
372
- 252: <span class="ruby-keyword kw">end</span>
373
- </pre>
374
- </div>
375
- </div>
376
- </div>
377
-
378
- <div id="method-M000034" class="method-detail">
379
- <a name="M000034"></a>
380
-
381
- <div class="method-heading">
382
- <a href="#M000034" class="method-signature">
383
- <span class="method-name">constantize</span><span class="method-args">()</span>
384
- </a>
385
- </div>
386
-
387
- <div class="method-description">
388
- <p>
389
- Returns a constant of the string.
390
- </p>
391
- <p>
392
- Examples:
393
- </p>
394
- <pre>
395
- &quot;User&quot;.constantize # =&gt; User
396
- &quot;HomeController&quot;.constantize # =&gt; HomeController
397
- &quot;Mack::Configuration&quot; # =&gt; Mack::Configuration
398
- </pre>
399
- <p><a class="source-toggle" href="#"
400
- onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
401
- <div class="method-source-code" id="M000034-source">
402
- <pre>
403
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 25</span>
404
- 25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">constantize</span>
405
- 26: <span class="ruby-constant">Module</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-node">&quot;::#{self}&quot;</span>)
406
- 27: <span class="ruby-keyword kw">end</span>
407
- </pre>
408
- </div>
409
- </div>
410
- </div>
411
-
412
- <div id="method-M000042" class="method-detail">
413
- <a name="M000042"></a>
414
-
415
- <div class="method-heading">
416
- <a href="#M000042" class="method-signature">
417
- <span class="method-name">ends_with?</span><span class="method-args">(x)</span>
418
- </a>
419
- </div>
420
-
421
- <div class="method-description">
422
- <p><a class="source-toggle" href="#"
423
- onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
424
- <div class="method-source-code" id="M000042-source">
425
- <pre>
426
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 165</span>
427
- 165: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ends_with?</span>(<span class="ruby-identifier">x</span>)
428
- 166: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">match</span>(<span class="ruby-node">/#{x}$/</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
429
- 167: <span class="ruby-keyword kw">end</span>
430
- </pre>
431
- </div>
432
- </div>
433
- </div>
434
-
435
- <div id="method-M000048" class="method-detail">
436
- <a name="M000048"></a>
437
-
438
- <div class="method-heading">
439
- <a href="#M000048" class="method-signature">
440
- <span class="method-name">hexdigest</span><span class="method-args">()</span>
441
- </a>
442
- </div>
443
-
444
- <div class="method-description">
445
- <p><a class="source-toggle" href="#"
446
- onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
447
- <div class="method-source-code" id="M000048-source">
448
- <pre>
449
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 216</span>
450
- 216: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hexdigest</span>
451
- 217: <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>.<span class="ruby-identifier">downcase</span>)
452
- 218: <span class="ruby-keyword kw">end</span>
453
- </pre>
454
- </div>
455
- </div>
456
- </div>
457
-
458
- <div id="method-M000049" class="method-detail">
459
- <a name="M000049"></a>
460
-
461
- <div class="method-heading">
462
- <a href="#M000049" class="method-signature">
463
- <span class="method-name">hexdigest!</span><span class="method-args">()</span>
464
- </a>
465
- </div>
466
-
467
- <div class="method-description">
468
- <p><a class="source-toggle" href="#"
469
- onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
470
- <div class="method-source-code" id="M000049-source">
471
- <pre>
472
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 220</span>
473
- 220: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hexdigest!</span>
474
- 221: <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>)
475
- 222: <span class="ruby-keyword kw">end</span>
476
- </pre>
477
- </div>
478
- </div>
479
- </div>
480
-
481
- <div id="method-M000038" class="method-detail">
482
- <a name="M000038"></a>
483
-
484
- <div class="method-heading">
485
- <a href="#M000038" class="method-signature">
486
- <span class="method-name">linkify</span><span class="method-args">(enabled = true, options = {}) {|t, url, options| ...}</span>
487
- </a>
488
- </div>
489
-
490
- <div class="method-description">
491
- <p><a class="source-toggle" href="#"
492
- onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
493
- <div class="method-source-code" id="M000038-source">
494
- <pre>
495
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 44</span>
496
- 44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">linkify</span>(<span class="ruby-identifier">enabled</span> = <span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
497
- 45: <span class="ruby-identifier">text</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span>
498
- 46: <span class="ruby-identifier">m</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/\&quot;([^&quot;]+)\&quot;\:([^:]+\:\S+)/</span>)
499
- 47: <span class="ruby-keyword kw">until</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">nil?</span>
500
- 48: <span class="ruby-identifier">y</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">to_s</span>
501
- 49: <span class="ruby-identifier">t</span> = <span class="ruby-identifier">m</span>[<span class="ruby-value">1</span>]
502
- 50: <span class="ruby-identifier">url</span> = <span class="ruby-identifier">m</span>[<span class="ruby-value">2</span>]
503
- 51:
504
- 52: <span class="ruby-comment cmt"># The code below handles punctuation or p tags being mistakenly added to the url when the link is at the end of a sentence or body</span>
505
- 53: <span class="ruby-identifier">url_punct_match</span> = <span class="ruby-regexp re">/\W*[&amp;nbsp;]*[\&lt;\/p\&gt;]*$/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">url</span>)
506
- 54: <span class="ruby-identifier">punct</span> = <span class="ruby-value str">''</span>
507
- 55: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">url_punct_match</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">url_punct_match</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">!=</span> <span class="ruby-value str">&quot;&quot;</span>
508
- 56: <span class="ruby-identifier">url</span>.<span class="ruby-identifier">chomp!</span>(<span class="ruby-identifier">url_punct_match</span>[<span class="ruby-value">0</span>])
509
- 57: <span class="ruby-identifier">punct</span> = <span class="ruby-identifier">url_punct_match</span>[<span class="ruby-value">0</span>] <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">url_punct_match</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;=&quot;</span>
510
- 58: <span class="ruby-keyword kw">end</span>
511
- 59:
512
- 60: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
513
- 61: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">enabled</span>
514
- 62: <span class="ruby-identifier">ret</span> = <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">t</span>, <span class="ruby-identifier">url</span>, <span class="ruby-identifier">options</span>
515
- 63: <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">y</span>, <span class="ruby-identifier">ret</span>)
516
- 64: <span class="ruby-keyword kw">else</span>
517
- 65: <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">y</span>, <span class="ruby-identifier">t</span>.<span class="ruby-identifier">to_s</span>)
518
- 66: <span class="ruby-keyword kw">end</span>
519
- 67: <span class="ruby-keyword kw">else</span>
520
- 68: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">enabled</span>
521
- 69: <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">y</span>, <span class="ruby-node">&quot;&lt;a href=\&quot;#{url}\&quot; #{options.join(&quot;%s=\&quot;%s\&quot;&quot;, &quot; &quot;)}&gt;#{t}&lt;/a&gt;#{punct}&quot;</span>)<span class="ruby-comment cmt"># punct places punctuation back into proper place</span>
522
- 70: <span class="ruby-keyword kw">else</span>
523
- 71: <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">y</span>, <span class="ruby-identifier">t</span>.<span class="ruby-identifier">to_s</span>)
524
- 72: <span class="ruby-keyword kw">end</span>
525
- 73: <span class="ruby-keyword kw">end</span>
526
- 74: <span class="ruby-identifier">m</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/\&quot;([^&quot;]+)\&quot;\:([^:]+\:\S+)/</span>)
527
- 75: <span class="ruby-keyword kw">end</span>
528
- 76: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">text</span>
529
- 77: <span class="ruby-keyword kw">end</span>
530
- </pre>
531
- </div>
532
- </div>
533
- </div>
534
-
535
- <div id="method-M000039" class="method-detail">
536
- <a name="M000039"></a>
537
-
538
- <div class="method-heading">
539
- <a href="#M000039" class="method-signature">
540
- <span class="method-name">methodize</span><span class="method-args">()</span>
541
- </a>
542
- </div>
543
-
544
- <div class="method-description">
545
- <p><a class="source-toggle" href="#"
546
- onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
547
- <div class="method-source-code" id="M000039-source">
548
- <pre>
549
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 79</span>
550
- 79: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">methodize</span>
551
- 80: <span class="ruby-identifier">x</span> = <span class="ruby-keyword kw">self</span>
552
- 81:
553
- 82: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
554
- 83: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{self} cannot be converted to a valid method name!&quot;</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>
555
- 84:
556
- 85: <span class="ruby-comment cmt"># get rid of the big stuff in the front/back</span>
557
- 86: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">strip!</span>
558
- 87:
559
- 88: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
560
- 89: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{self} cannot be converted to a valid method name!&quot;</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>
561
- 90:
562
- 91: <span class="ruby-identifier">x</span> = <span class="ruby-identifier">x</span>.<span class="ruby-identifier">underscore</span>
563
- 92:
564
- 93: <span class="ruby-comment cmt"># get rid of spaces and make the _</span>
565
- 94: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">' '</span>, <span class="ruby-value str">'_'</span>)
566
- 95: <span class="ruby-comment cmt"># get rid of everything that isn't 'safe' a-z, 0-9, ?, !, =, _</span>
567
- 96: <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>)
568
- 97:
569
- 98: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
570
- 99: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{self} cannot be converted to a valid method name!&quot;</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>
571
- 100:
572
- 101: <span class="ruby-comment cmt"># condense multiple 'safe' non a-z chars to just one.</span>
573
- 102: <span class="ruby-comment cmt"># ie. ___ becomes _ !!!! becomes ! etc...</span>
574
- 103: [<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">&quot;=&quot;</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>
575
- 104: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">squeeze!</span>(<span class="ruby-identifier">c</span>)
576
- 105: <span class="ruby-keyword kw">end</span>
577
- 106:
578
- 107: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
579
- 108: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{self} cannot be converted to a valid method name!&quot;</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>
580
- 109:
581
- 110: <span class="ruby-comment cmt">#down case the whole thing</span>
582
- 111: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">downcase!</span>
583
- 112:
584
- 113: <span class="ruby-comment cmt"># get rid of any characters at the beginning that aren't a-z</span>
585
- 114: <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>)
586
- 115: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">0</span>)
587
- 116:
588
- 117: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
589
- 118: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{self} cannot be converted to a valid method name!&quot;</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>
590
- 119: <span class="ruby-keyword kw">end</span>
591
- 120:
592
- 121: <span class="ruby-comment cmt"># let's trim this bad boy down a bit now that we've cleaned it up, somewhat.</span>
593
- 122: <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>
594
- 123: <span class="ruby-comment cmt"># bad char at the end if you trim too late.</span>
595
- 124: <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">&gt;</span> <span class="ruby-value">100</span>
596
- 125:
597
- 126: <span class="ruby-comment cmt"># get rid of any characters at the end that aren't safe</span>
598
- 127: <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>)
599
- 128: <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>)
600
- 129: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
601
- 130: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{self} cannot be converted to a valid method name!&quot;</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>
602
- 131: <span class="ruby-keyword kw">end</span>
603
- 132:
604
- 133: <span class="ruby-comment cmt"># if we get down to a nil or an empty string raise an exception! </span>
605
- 134: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{self} cannot be converted to a valid method name!&quot;</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>
606
- 135:
607
- 136: <span class="ruby-comment cmt"># let's get rid of characters that don't belong in the 'middle' of the method.</span>
608
- 137: <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>)]
609
- 138: <span class="ruby-identifier">n_middle</span> = <span class="ruby-identifier">orig_middle</span>.<span class="ruby-identifier">dup</span>
610
- 139:
611
- 140: [<span class="ruby-value str">'?'</span>, <span class="ruby-value str">'!'</span>, <span class="ruby-value str">&quot;=&quot;</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>
612
- 141: <span class="ruby-identifier">n_middle</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">c</span>, <span class="ruby-value str">&quot;_&quot;</span>)
613
- 142: <span class="ruby-keyword kw">end</span>
614
- 143:
615
- 144: <span class="ruby-comment cmt"># the previous gsub can leave us with multiple underscores that need cleaning up.</span>
616
- 145: <span class="ruby-identifier">n_middle</span>.<span class="ruby-identifier">squeeze!</span>(<span class="ruby-value str">&quot;_&quot;</span>)
617
- 146:
618
- 147: <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>)
619
- 148: <span class="ruby-identifier">x</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">&quot;_=&quot;</span>, <span class="ruby-value str">&quot;=&quot;</span>)
620
- 149: <span class="ruby-identifier">x</span>
621
- 150: <span class="ruby-keyword kw">end</span>
622
- </pre>
623
- </div>
624
- </div>
625
- </div>
626
-
627
- <div id="method-M000036" class="method-detail">
628
- <a name="M000036"></a>
629
-
630
- <div class="method-heading">
631
- <a href="#M000036" class="method-signature">
632
- <span class="method-name">plural</span><span class="method-args">()</span>
633
- </a>
634
- </div>
635
-
636
- <div class="method-description">
637
- <p>
638
- Maps to Mack::Utils::Inflector.instance.pluralize
639
- </p>
640
- <p><a class="source-toggle" href="#"
641
- onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
642
- <div class="method-source-code" id="M000036-source">
643
- <pre>
644
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 35</span>
645
- 35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">plural</span>
646
- 36: <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">Inflector</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">pluralize</span>(<span class="ruby-keyword kw">self</span>)
647
- 37: <span class="ruby-keyword kw">end</span>
648
- </pre>
649
- </div>
650
- </div>
651
- </div>
652
-
653
- <div id="method-M000044" class="method-detail">
654
- <a name="M000044"></a>
655
-
656
- <div class="method-heading">
657
- <a href="#M000044" class="method-signature">
658
- <span class="method-name">remove</span><span class="method-args">(val)</span>
659
- </a>
660
- </div>
661
-
662
- <div class="method-description">
663
- <p><a class="source-toggle" href="#"
664
- onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
665
- <div class="method-source-code" id="M000044-source">
666
- <pre>
667
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 175</span>
668
- 175: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove</span>(<span class="ruby-identifier">val</span>)
669
- 176: <span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">val</span>, <span class="ruby-value str">''</span>)
670
- 177: <span class="ruby-keyword kw">end</span>
671
- </pre>
672
- </div>
673
- </div>
674
- </div>
675
-
676
- <div id="method-M000045" class="method-detail">
677
- <a name="M000045"></a>
678
-
679
- <div class="method-heading">
680
- <a href="#M000045" class="method-signature">
681
- <span class="method-name">remove!</span><span class="method-args">(val)</span>
682
- </a>
683
- </div>
684
-
685
- <div class="method-description">
686
- <p><a class="source-toggle" href="#"
687
- onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
688
- <div class="method-source-code" id="M000045-source">
689
- <pre>
690
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 179</span>
691
- 179: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove!</span>(<span class="ruby-identifier">val</span>)
692
- 180: <span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">val</span>, <span class="ruby-value str">''</span>)
693
- 181: <span class="ruby-keyword kw">end</span>
694
- </pre>
695
- </div>
696
- </div>
697
- </div>
698
-
699
- <div id="method-M000037" class="method-detail">
700
- <a name="M000037"></a>
701
-
702
- <div class="method-heading">
703
- <a href="#M000037" class="method-signature">
704
- <span class="method-name">singular</span><span class="method-args">()</span>
705
- </a>
706
- </div>
707
-
708
- <div class="method-description">
709
- <p>
710
- Maps to Mack::Utils::Inflector.instance.singularize
711
- </p>
712
- <p><a class="source-toggle" href="#"
713
- onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
714
- <div class="method-source-code" id="M000037-source">
715
- <pre>
716
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 40</span>
717
- 40: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">singular</span>
718
- 41: <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">Inflector</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">singularize</span>(<span class="ruby-keyword kw">self</span>)
719
- 42: <span class="ruby-keyword kw">end</span>
720
- </pre>
721
- </div>
722
- </div>
723
- </div>
724
-
725
- <div id="method-M000055" class="method-detail">
726
- <a name="M000055"></a>
727
-
728
- <div class="method-heading">
729
- <a href="#M000055" class="method-signature">
730
- <span class="method-name">sql_safe_str</span><span class="method-args">()</span>
731
- </a>
732
- </div>
733
-
734
- <div class="method-description">
735
- <p>
736
- keep adding on to this whenever it becomes apparent that unsafe strings
737
- could get passed through into the database
738
- </p>
739
- <p><a class="source-toggle" href="#"
740
- onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
741
- <div class="method-source-code" id="M000055-source">
742
- <pre>
743
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 256</span>
744
- 256: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sql_safe_str</span>
745
- 257: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">nil?</span>
746
- 258: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[\']/</span>, <span class="ruby-value str">&quot;\'\'&quot;</span>)
747
- 259: <span class="ruby-keyword kw">end</span>
748
- 260: <span class="ruby-keyword kw">end</span>
749
- </pre>
750
- </div>
751
- </div>
752
- </div>
753
-
754
- <div id="method-M000056" class="method-detail">
755
- <a name="M000056"></a>
756
-
757
- <div class="method-heading">
758
- <a href="#M000056" class="method-signature">
759
- <span class="method-name">sql_safe_str!</span><span class="method-args">()</span>
760
- </a>
761
- </div>
762
-
763
- <div class="method-description">
764
- <p><a class="source-toggle" href="#"
765
- onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
766
- <div class="method-source-code" id="M000056-source">
767
- <pre>
768
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 262</span>
769
- 262: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sql_safe_str!</span>
770
- 263: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">sql_safe_str</span>)
771
- 264: <span class="ruby-keyword kw">end</span>
772
- </pre>
773
- </div>
774
- </div>
775
- </div>
776
-
777
- <div id="method-M000041" class="method-detail">
778
- <a name="M000041"></a>
779
-
780
- <div class="method-heading">
781
- <a href="#M000041" class="method-signature">
782
- <span class="method-name">starts_with?</span><span class="method-args">(x)</span>
783
- </a>
784
- </div>
785
-
786
- <div class="method-description">
787
- <p><a class="source-toggle" href="#"
788
- onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
789
- <div class="method-source-code" id="M000041-source">
790
- <pre>
791
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 161</span>
792
- 161: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">starts_with?</span>(<span class="ruby-identifier">x</span>)
793
- 162: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">match</span>(<span class="ruby-node">/^#{x}/</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
794
- 163: <span class="ruby-keyword kw">end</span>
795
- </pre>
796
- </div>
797
- </div>
798
- </div>
799
-
800
- <div id="method-M000032" class="method-detail">
801
- <a name="M000032"></a>
802
-
803
- <div class="method-heading">
804
- <a href="#M000032" class="method-signature">
805
- <span class="method-name">to_instance</span><span class="method-args">()</span>
806
- </a>
807
- </div>
808
-
809
- <div class="method-description">
810
- <p>
811
- See <a href="Class.html">Class</a> new_instance_of for more details.
812
- </p>
813
- <p><a class="source-toggle" href="#"
814
- onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
815
- <div class="method-source-code" id="M000032-source">
816
- <pre>
817
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 5</span>
818
- 5: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_instance</span>
819
- 6: <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new_instance_of</span>(<span class="ruby-keyword kw">self</span>)
820
- 7: <span class="ruby-keyword kw">end</span>
821
- </pre>
822
- </div>
823
- </div>
824
- </div>
825
-
826
- <div id="method-M000051" class="method-detail">
827
- <a name="M000051"></a>
828
-
829
- <div class="method-heading">
830
- <a href="#M000051" class="method-signature">
831
- <span class="method-name">truncate</span><span class="method-args">(length = 30, truncate_string = &quot;...&quot;)</span>
832
- </a>
833
- </div>
834
-
835
- <div class="method-description">
836
- <p><a class="source-toggle" href="#"
837
- onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
838
- <div class="method-source-code" id="M000051-source">
839
- <pre>
840
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 231</span>
841
- 231: <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">&quot;...&quot;</span>)
842
- 232: <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>
843
- 233: <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>
844
- 234: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$KCODE</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;NONE&quot;</span>
845
- 235: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</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>
846
- 236: <span class="ruby-keyword kw">else</span>
847
- 237: <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>)
848
- 238: <span class="ruby-identifier">chars</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</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>
849
- 239: <span class="ruby-keyword kw">end</span>
850
- 240: <span class="ruby-keyword kw">end</span>
851
- </pre>
852
- </div>
853
- </div>
854
- </div>
855
-
856
- <div id="method-M000052" class="method-detail">
857
- <a name="M000052"></a>
858
-
859
- <div class="method-heading">
860
- <a href="#M000052" class="method-signature">
861
- <span class="method-name">truncate!</span><span class="method-args">(length = 30, truncate_string = &quot;...&quot;)</span>
862
- </a>
863
- </div>
864
-
865
- <div class="method-description">
866
- <p><a class="source-toggle" href="#"
867
- onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
868
- <div class="method-source-code" id="M000052-source">
869
- <pre>
870
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 242</span>
871
- 242: <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">&quot;...&quot;</span>)
872
- 243: <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>))
873
- 244: <span class="ruby-keyword kw">end</span>
874
- </pre>
875
- </div>
876
- </div>
877
- </div>
878
-
879
- <div id="method-M000040" class="method-detail">
880
- <a name="M000040"></a>
881
-
882
- <div class="method-heading">
883
- <a href="#M000040" class="method-signature">
884
- <span class="method-name">underscore</span><span class="method-args">()</span>
885
- </a>
886
- </div>
887
-
888
- <div class="method-description">
889
- <p><a class="source-toggle" href="#"
890
- onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
891
- <div class="method-source-code" id="M000040-source">
892
- <pre>
893
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 152</span>
894
- 152: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">underscore</span>
895
- 153: <span class="ruby-identifier">camel_cased_word</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span>
896
- 154: <span class="ruby-identifier">camel_cased_word</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/::/</span>, <span class="ruby-value str">'/'</span>).
897
- 155: <span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/([A-Z]+)([A-Z][a-z])/</span>,<span class="ruby-value str">'\1_\2'</span>).
898
- 156: <span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/([a-z\d])([A-Z])/</span>,<span class="ruby-value str">'\1_\2'</span>).
899
- 157: <span class="ruby-identifier">tr</span>(<span class="ruby-value str">&quot;-&quot;</span>, <span class="ruby-value str">&quot;_&quot;</span>).
900
- 158: <span class="ruby-identifier">downcase</span>
901
- 159: <span class="ruby-keyword kw">end</span>
902
- </pre>
903
- </div>
904
- </div>
905
- </div>
906
-
907
- <div id="method-M000057" class="method-detail">
908
- <a name="M000057"></a>
909
-
910
- <div class="method-heading">
911
- <a href="#M000057" class="method-signature">
912
- <span class="method-name">uri_escape</span><span class="method-args">()</span>
913
- </a>
914
- </div>
915
-
916
- <div class="method-description">
917
- <p>
918
- Performs URI escaping so that you can construct proper query strings
919
- faster. Use this rather than the cgi.rb version since it&#8216;s faster.
920
- (Stolen from Camping).
921
- </p>
922
- <p><a class="source-toggle" href="#"
923
- onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
924
- <div class="method-source-code" id="M000057-source">
925
- <pre>
926
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 269</span>
927
- 269: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uri_escape</span>
928
- 270: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/([^ a-zA-Z0-9_.-]+)/n</span>) {
929
- 271: <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>
930
- 272: }.<span class="ruby-identifier">tr</span>(<span class="ruby-value str">' '</span>, <span class="ruby-value str">'+'</span>)
931
- 273: <span class="ruby-keyword kw">end</span>
932
- </pre>
933
- </div>
934
- </div>
935
- </div>
936
-
937
- <div id="method-M000058" class="method-detail">
938
- <a name="M000058"></a>
939
-
940
- <div class="method-heading">
941
- <a href="#M000058" class="method-signature">
942
- <span class="method-name">uri_unescape</span><span class="method-args">()</span>
943
- </a>
944
- </div>
945
-
946
- <div class="method-description">
947
- <p>
948
- Unescapes a URI escaped string. (Stolen from Camping).
949
- </p>
950
- <p><a class="source-toggle" href="#"
951
- onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
952
- <div class="method-source-code" id="M000058-source">
953
- <pre>
954
- <span class="ruby-comment cmt"># File lib/extensions/string.rb, line 276</span>
955
- 276: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uri_unescape</span>
956
- 277: <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>){
957
- 278: [<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>)
958
- 279: }
959
- 280: <span class="ruby-keyword kw">end</span>
960
- </pre>
961
- </div>
962
- </div>
963
- </div>
964
-
965
-
966
- </div>
967
-
968
-
969
- </div>
970
-
971
-
972
- <div id="validator-badges">
973
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
974
- </div>
975
-
976
- </body>
977
- </html>