mack-facets 0.7.0.1 → 0.7.1

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