mack_ruby_core_extensions 0.1.1 → 0.1.3

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