mack-facets 0.6.0.1 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. data/README +4 -3
  2. data/lib/{english_extensions → mack-facets/english_extensions}/inflect.rb +0 -0
  3. data/lib/{english_extensions → mack-facets/english_extensions}/numerals.rb +0 -0
  4. data/lib/{extensions → mack-facets/extensions}/array.rb +0 -0
  5. data/lib/{extensions → mack-facets/extensions}/class.rb +0 -0
  6. data/lib/{extensions → mack-facets/extensions}/hash.rb +0 -0
  7. data/lib/{extensions → mack-facets/extensions}/kernel.rb +0 -0
  8. data/lib/{extensions → mack-facets/extensions}/math.rb +0 -0
  9. data/lib/{extensions → mack-facets/extensions}/module.rb +0 -0
  10. data/lib/mack-facets/extensions/nil_class.rb +7 -0
  11. data/lib/{extensions → mack-facets/extensions}/object.rb +0 -0
  12. data/lib/{extensions → mack-facets/extensions}/string.rb +0 -0
  13. data/lib/{extensions → mack-facets/extensions}/symbol.rb +0 -0
  14. data/lib/{utils → mack-facets/utils}/inflections.rb +0 -0
  15. data/lib/{utils → mack-facets/utils}/inflector.rb +0 -0
  16. data/lib/{utils → mack-facets/utils}/options_merger.rb +0 -0
  17. data/lib/mack-facets/utils/registry_list.rb +83 -0
  18. data/lib/mack-facets/utils/registry_map.rb +94 -0
  19. data/lib/mack-facets.rb +11 -8
  20. metadata +29 -48
  21. data/doc/classes/Array.html +0 -408
  22. data/doc/classes/Class.html +0 -233
  23. data/doc/classes/Hash.html +0 -233
  24. data/doc/classes/Kernel.html +0 -184
  25. data/doc/classes/Mack/Utils/Inflector.html +0 -382
  26. data/doc/classes/Math.html +0 -188
  27. data/doc/classes/Module.html +0 -203
  28. data/doc/classes/Object.html +0 -558
  29. data/doc/classes/String.html +0 -451
  30. data/doc/classes/Symbol.html +0 -148
  31. data/doc/created.rid +0 -1
  32. data/doc/files/README.html +0 -111
  33. data/doc/files/lib/english_extensions/inflect_rb.html +0 -101
  34. data/doc/files/lib/english_extensions/numerals_rb.html +0 -101
  35. data/doc/files/lib/extensions/array_rb.html +0 -101
  36. data/doc/files/lib/extensions/class_rb.html +0 -101
  37. data/doc/files/lib/extensions/hash_rb.html +0 -108
  38. data/doc/files/lib/extensions/kernel_rb.html +0 -109
  39. data/doc/files/lib/extensions/math_rb.html +0 -101
  40. data/doc/files/lib/extensions/module_rb.html +0 -101
  41. data/doc/files/lib/extensions/object_rb.html +0 -101
  42. data/doc/files/lib/extensions/string_rb.html +0 -101
  43. data/doc/files/lib/extensions/symbol_rb.html +0 -101
  44. data/doc/files/lib/mack-facets_rb.html +0 -120
  45. data/doc/files/lib/utils/inflections_rb.html +0 -101
  46. data/doc/files/lib/utils/inflector_rb.html +0 -108
  47. data/doc/files/lib/utils/options_merger_rb.html +0 -101
  48. data/doc/fr_class_index.html +0 -36
  49. data/doc/fr_file_index.html +0 -42
  50. data/doc/fr_method_index.html +0 -75
  51. data/doc/index.html +0 -24
  52. data/doc/rdoc-style.css +0 -208
@@ -1,408 +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: Array</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">Array</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/extensions/array_rb.html">
59
- lib/extensions/array.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="#M000012">count</a>&nbsp;&nbsp;
92
- <a href="#M000013">invert</a>&nbsp;&nbsp;
93
- <a href="#M000005">parse_splat_args</a>&nbsp;&nbsp;
94
- <a href="#M000008">pick_random</a>&nbsp;&nbsp;
95
- <a href="#M000009">random_each</a>&nbsp;&nbsp;
96
- <a href="#M000006">randomize</a>&nbsp;&nbsp;
97
- <a href="#M000007">randomize!</a>&nbsp;&nbsp;
98
- <a href="#M000010">subset?</a>&nbsp;&nbsp;
99
- <a href="#M000011">superset?</a>&nbsp;&nbsp;
100
- </div>
101
- </div>
102
-
103
- </div>
104
-
105
-
106
- <!-- if includes -->
107
-
108
- <div id="section">
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
- <!-- if method_list -->
118
- <div id="methods">
119
- <h3 class="section-bar">Public Instance methods</h3>
120
-
121
- <div id="method-M000012" class="method-detail">
122
- <a name="M000012"></a>
123
-
124
- <div class="method-heading">
125
- <a href="#M000012" class="method-signature">
126
- <span class="method-name">count</span><span class="method-args">()</span>
127
- </a>
128
- </div>
129
-
130
- <div class="method-description">
131
- <p>
132
- This will give you a <a href="Array.html#M000012">count</a>, as a <a
133
- href="Hash.html">Hash</a>, of all the values in the <a
134
- href="Array.html">Array</a>. %w{spam spam eggs ham eggs spam}.<a
135
- href="Array.html#M000012">count</a> # =&gt; {&quot;eggs&quot; =&gt; 2,
136
- &quot;ham&quot; =&gt; 1, &quot;spam&quot; =&gt; 3}
137
- </p>
138
- <p><a class="source-toggle" href="#"
139
- onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
140
- <div class="method-source-code" id="M000012-source">
141
- <pre>
142
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 76</span>
143
- 76: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">count</span>
144
- 77: <span class="ruby-identifier">k</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>)
145
- 78: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span>[<span class="ruby-identifier">x</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>}
146
- 79: <span class="ruby-identifier">k</span>
147
- 80: <span class="ruby-keyword kw">end</span>
148
- </pre>
149
- </div>
150
- </div>
151
- </div>
152
-
153
- <div id="method-M000013" class="method-detail">
154
- <a name="M000013"></a>
155
-
156
- <div class="method-heading">
157
- <a href="#M000013" class="method-signature">
158
- <span class="method-name">invert</span><span class="method-args">()</span>
159
- </a>
160
- </div>
161
-
162
- <div class="method-description">
163
- <p>
164
- This will <a href="Array.html#M000013">invert</a> the index and the values
165
- and return a <a href="Hash.html">Hash</a> of the results. %w{red yellow
166
- orange}.<a href="Array.html#M000013">invert</a> # =&gt; {&quot;red&quot;
167
- =&gt; 0, &quot;orange&quot; =&gt; 2, &quot;yellow&quot; =&gt; 1}
168
- </p>
169
- <p><a class="source-toggle" href="#"
170
- onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
171
- <div class="method-source-code" id="M000013-source">
172
- <pre>
173
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 84</span>
174
- 84: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">invert</span>
175
- 85: <span class="ruby-identifier">h</span> = {}
176
- 86: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each_with_index</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">x</span>,<span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">x</span>] = <span class="ruby-identifier">i</span>}
177
- 87: <span class="ruby-identifier">h</span>
178
- 88: <span class="ruby-keyword kw">end</span>
179
- </pre>
180
- </div>
181
- </div>
182
- </div>
183
-
184
- <div id="method-M000005" class="method-detail">
185
- <a name="M000005"></a>
186
-
187
- <div class="method-heading">
188
- <a href="#M000005" class="method-signature">
189
- <span class="method-name">parse_splat_args</span><span class="method-args">()</span>
190
- </a>
191
- </div>
192
-
193
- <div class="method-description">
194
- <p>
195
- This method is useful when you have a method that looks like this: def
196
- foo(*args)
197
- </p>
198
- <pre>
199
- do something
200
- </pre>
201
- <p>
202
- end The problem is when you use the * like that everything that comes in is
203
- an array. Here are a few problems with this: foo([1,2,3]) When you pass an
204
- array into this type of method you get the following nested array:
205
- [[1,2,3]] The <a href="Array.html#M000005">parse_splat_args</a> method, if
206
- called, would do this: args.parse_splat_args # =&gt; [1,2,3] Now say you
207
- called this method like such: foo(1) args would be [1]
208
- args.parse_splat_args # =&gt; 1 Finally foo args.parse_splat_args # =&gt;
209
- nil
210
- </p>
211
- <p><a class="source-toggle" href="#"
212
- onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
213
- <div class="method-source-code" id="M000005-source">
214
- <pre>
215
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 21</span>
216
- 21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_splat_args</span>
217
- 22: <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">empty?</span>
218
- 23: <span class="ruby-identifier">args</span> = <span class="ruby-keyword kw">self</span><span class="ruby-comment cmt">#.flatten</span>
219
- 24: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span>
220
- 25: <span class="ruby-keyword kw">when</span> <span class="ruby-value">1</span>
221
- 26: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span> <span class="ruby-comment cmt"># if there was only one arg passed, return just that, without the array</span>
222
- 27: <span class="ruby-keyword kw">when</span> <span class="ruby-value">0</span>
223
- 28: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># if no args were passed return nil</span>
224
- 29: <span class="ruby-keyword kw">else</span>
225
- 30: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">args</span> <span class="ruby-comment cmt"># else return the array back, cause chances are that's what they passed you!</span>
226
- 31: <span class="ruby-keyword kw">end</span>
227
- 32: <span class="ruby-keyword kw">end</span>
228
- 33: <span class="ruby-keyword kw">end</span>
229
- </pre>
230
- </div>
231
- </div>
232
- </div>
233
-
234
- <div id="method-M000008" class="method-detail">
235
- <a name="M000008"></a>
236
-
237
- <div class="method-heading">
238
- <a href="#M000008" class="method-signature">
239
- <span class="method-name">pick_random</span><span class="method-args">()</span>
240
- </a>
241
- </div>
242
-
243
- <div class="method-description">
244
- <p>
245
- This will pick a random value from the array
246
- </p>
247
- <p><a class="source-toggle" href="#"
248
- onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
249
- <div class="method-source-code" id="M000008-source">
250
- <pre>
251
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 54</span>
252
- 54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pick_random</span>
253
- 55: <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">rand</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span>)]
254
- 56: <span class="ruby-keyword kw">end</span>
255
- </pre>
256
- </div>
257
- </div>
258
- </div>
259
-
260
- <div id="method-M000009" class="method-detail">
261
- <a name="M000009"></a>
262
-
263
- <div class="method-heading">
264
- <a href="#M000009" class="method-signature">
265
- <span class="method-name">random_each</span><span class="method-args">() {|x| ...}</span>
266
- </a>
267
- </div>
268
-
269
- <div class="method-description">
270
- <p>
271
- This allows you to easily recurse of the array randomly.
272
- </p>
273
- <p><a class="source-toggle" href="#"
274
- onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
275
- <div class="method-source-code" id="M000009-source">
276
- <pre>
277
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 59</span>
278
- 59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">random_each</span>
279
- 60: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">randomize</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">x</span>}
280
- 61: <span class="ruby-keyword kw">end</span>
281
- </pre>
282
- </div>
283
- </div>
284
- </div>
285
-
286
- <div id="method-M000006" class="method-detail">
287
- <a name="M000006"></a>
288
-
289
- <div class="method-heading">
290
- <a href="#M000006" class="method-signature">
291
- <span class="method-name">randomize</span><span class="method-args">() {|x, y| ...}</span>
292
- </a>
293
- </div>
294
-
295
- <div class="method-description">
296
- <p>
297
- This will return a new instance of the array sorted randomly.
298
- </p>
299
- <p><a class="source-toggle" href="#"
300
- onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
301
- <div class="method-source-code" id="M000006-source">
302
- <pre>
303
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 36</span>
304
- 36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">randomize</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
305
- 37: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
306
- 38: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">sort</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span>}
307
- 39: <span class="ruby-keyword kw">else</span>
308
- 40: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">sort_by</span> { <span class="ruby-identifier">rand</span> }
309
- 41: <span class="ruby-keyword kw">end</span>
310
- 42: <span class="ruby-keyword kw">end</span>
311
- </pre>
312
- </div>
313
- </div>
314
- </div>
315
-
316
- <div id="method-M000007" class="method-detail">
317
- <a name="M000007"></a>
318
-
319
- <div class="method-heading">
320
- <a href="#M000007" class="method-signature">
321
- <span class="method-name">randomize!</span><span class="method-args">(&amp;block)</span>
322
- </a>
323
- </div>
324
-
325
- <div class="method-description">
326
- <p>
327
- This calls the <a href="Array.html#M000006">randomize</a> method, but will
328
- permantly replace the existing array.
329
- </p>
330
- <p><a class="source-toggle" href="#"
331
- onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
332
- <div class="method-source-code" id="M000007-source">
333
- <pre>
334
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 45</span>
335
- 45: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">randomize!</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
336
- 46: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
337
- 47: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">randomize</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>))
338
- 48: <span class="ruby-keyword kw">else</span>
339
- 49: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">randomize</span>)
340
- 50: <span class="ruby-keyword kw">end</span>
341
- 51: <span class="ruby-keyword kw">end</span>
342
- </pre>
343
- </div>
344
- </div>
345
- </div>
346
-
347
- <div id="method-M000010" class="method-detail">
348
- <a name="M000010"></a>
349
-
350
- <div class="method-heading">
351
- <a href="#M000010" class="method-signature">
352
- <span class="method-name">subset?</span><span class="method-args">(other)</span>
353
- </a>
354
- </div>
355
-
356
- <div class="method-description">
357
- <p><a class="source-toggle" href="#"
358
- onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
359
- <div class="method-source-code" id="M000010-source">
360
- <pre>
361
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 63</span>
362
- 63: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">subset?</span>(<span class="ruby-identifier">other</span>)
363
- 64: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span>
364
- 65: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">x</span>)
365
- 66: <span class="ruby-keyword kw">end</span>
366
- 67: <span class="ruby-keyword kw">true</span>
367
- 68: <span class="ruby-keyword kw">end</span>
368
- </pre>
369
- </div>
370
- </div>
371
- </div>
372
-
373
- <div id="method-M000011" class="method-detail">
374
- <a name="M000011"></a>
375
-
376
- <div class="method-heading">
377
- <a href="#M000011" class="method-signature">
378
- <span class="method-name">superset?</span><span class="method-args">(other)</span>
379
- </a>
380
- </div>
381
-
382
- <div class="method-description">
383
- <p><a class="source-toggle" href="#"
384
- onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
385
- <div class="method-source-code" id="M000011-source">
386
- <pre>
387
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 70</span>
388
- 70: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">superset?</span>(<span class="ruby-identifier">other</span>)
389
- 71: <span class="ruby-identifier">other</span>.<span class="ruby-identifier">subset?</span>(<span class="ruby-keyword kw">self</span>)
390
- 72: <span class="ruby-keyword kw">end</span>
391
- </pre>
392
- </div>
393
- </div>
394
- </div>
395
-
396
-
397
- </div>
398
-
399
-
400
- </div>
401
-
402
-
403
- <div id="validator-badges">
404
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
405
- </div>
406
-
407
- </body>
408
- </html>
@@ -1,233 +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: Class</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">Class</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/extensions/class_rb.html">
59
- lib/extensions/class.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="#M000017">class_is_a?</a>&nbsp;&nbsp;
92
- <a href="#M000016">new_instance_of</a>&nbsp;&nbsp;
93
- <a href="#M000018">parents</a>&nbsp;&nbsp;
94
- </div>
95
- </div>
96
-
97
- </div>
98
-
99
-
100
- <!-- if includes -->
101
-
102
- <div id="section">
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
- <!-- if method_list -->
112
- <div id="methods">
113
- <h3 class="section-bar">Public Class methods</h3>
114
-
115
- <div id="method-M000016" class="method-detail">
116
- <a name="M000016"></a>
117
-
118
- <div class="method-heading">
119
- <a href="#M000016" class="method-signature">
120
- <span class="method-name">new_instance_of</span><span class="method-args">(klass_name)</span>
121
- </a>
122
- </div>
123
-
124
- <div class="method-description">
125
- <p>
126
- Returns a new <a href="Object.html">Object</a> instance of the class name
127
- specified.
128
- </p>
129
- <p>
130
- Examples:
131
- </p>
132
- <pre>
133
- Class.new_instance_of(&quot;Orange&quot;) =&gt; #&lt;Orange:0x376c0c&gt;
134
- Class.new_instance_of(&quot;Animals::Dog&quot;) =&gt; #&lt;Animals::Dog:0x376a2c&gt;
135
- </pre>
136
- <p><a class="source-toggle" href="#"
137
- onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
138
- <div class="method-source-code" id="M000016-source">
139
- <pre>
140
- <span class="ruby-comment cmt"># File lib/extensions/class.rb, line 8</span>
141
- 8: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new_instance_of</span>(<span class="ruby-identifier">klass_name</span>)
142
- 9: <span class="ruby-identifier">klass_name</span>.<span class="ruby-identifier">constantize</span>.<span class="ruby-identifier">new</span>
143
- 10: <span class="ruby-keyword kw">end</span>
144
- </pre>
145
- </div>
146
- </div>
147
- </div>
148
-
149
- <h3 class="section-bar">Public Instance methods</h3>
150
-
151
- <div id="method-M000017" class="method-detail">
152
- <a name="M000017"></a>
153
-
154
- <div class="method-heading">
155
- <a href="#M000017" class="method-signature">
156
- <span class="method-name">class_is_a?</span><span class="method-args">(klass_name)</span>
157
- </a>
158
- </div>
159
-
160
- <div class="method-description">
161
- <p>
162
- This will through the ancestor tree of object and tell you if that object
163
- is of the specified type.
164
- </p>
165
- <p><a class="source-toggle" href="#"
166
- onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
167
- <div class="method-source-code" id="M000017-source">
168
- <pre>
169
- <span class="ruby-comment cmt"># File lib/extensions/class.rb, line 14</span>
170
- 14: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">class_is_a?</span>(<span class="ruby-identifier">klass_name</span>)
171
- 15: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">ancestors</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">an</span><span class="ruby-operator">|</span>
172
- 16: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">an</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">klass_name</span>
173
- 17: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
174
- 18: <span class="ruby-keyword kw">end</span>
175
- 19: <span class="ruby-keyword kw">end</span>
176
- 20: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
177
- 21: <span class="ruby-keyword kw">end</span>
178
- </pre>
179
- </div>
180
- </div>
181
- </div>
182
-
183
- <div id="method-M000018" class="method-detail">
184
- <a name="M000018"></a>
185
-
186
- <div class="method-heading">
187
- <a href="#M000018" class="method-signature">
188
- <span class="method-name">parents</span><span class="method-args">()</span>
189
- </a>
190
- </div>
191
-
192
- <div class="method-description">
193
- <p>
194
- Returns an array of the classes parent classes.
195
- </p>
196
- <p>
197
- Examples:
198
- </p>
199
- <pre>
200
- Orange.parents # =&gt; [Citrus, Fruit, Object]
201
- Citrus.parents # =&gt; [Fruit, Object]
202
- Fruit.parents # =&gt; [Object]
203
- </pre>
204
- <p><a class="source-toggle" href="#"
205
- onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
206
- <div class="method-source-code" id="M000018-source">
207
- <pre>
208
- <span class="ruby-comment cmt"># File lib/extensions/class.rb, line 29</span>
209
- 29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parents</span>
210
- 30: <span class="ruby-identifier">ans</span> = [<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">superclass</span>]
211
- 31: <span class="ruby-keyword kw">until</span> <span class="ruby-identifier">ans</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">superclass</span>.<span class="ruby-identifier">nil?</span>
212
- 32: <span class="ruby-identifier">ans</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ans</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">superclass</span>
213
- 33: <span class="ruby-keyword kw">end</span>
214
- 34: <span class="ruby-identifier">ans</span>
215
- 35: <span class="ruby-keyword kw">end</span>
216
- </pre>
217
- </div>
218
- </div>
219
- </div>
220
-
221
-
222
- </div>
223
-
224
-
225
- </div>
226
-
227
-
228
- <div id="validator-badges">
229
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
230
- </div>
231
-
232
- </body>
233
- </html>