facets 2.5.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -1
- data/CHANGES +28 -45
- data/MANIFEST +35 -4
- data/README +3 -14
- data/RELEASE +36 -70
- data/VERSION +1 -1
- data/doc/archive/RELEASE-2.5.0 +83 -0
- data/doc/log/basic_stats/index.html +4 -4
- data/doc/log/changelog.html +509 -2
- data/doc/log/changelog.txt +130 -1522
- data/doc/rdoc/core/classes/Array.html +366 -141
- data/doc/rdoc/core/classes/Binding.html +45 -45
- data/doc/rdoc/core/classes/Class.html +38 -38
- data/doc/rdoc/core/classes/Comparable.html +26 -26
- data/doc/rdoc/core/classes/Enumerable.html +174 -170
- data/doc/rdoc/core/classes/Enumerable/Enumerator.html +130 -0
- data/doc/rdoc/core/classes/Enumerator.html +132 -0
- data/doc/rdoc/core/classes/Exception.html +8 -8
- data/doc/rdoc/core/classes/File.html +58 -58
- data/doc/rdoc/core/classes/FileTest.html +4 -4
- data/doc/rdoc/core/classes/Float.html +8 -8
- data/doc/rdoc/core/classes/Functor.html +12 -12
- data/doc/rdoc/core/classes/Hash.html +447 -263
- data/doc/rdoc/core/classes/Indexable.html +110 -110
- data/doc/rdoc/core/classes/Integer.html +2 -2
- data/doc/rdoc/core/classes/Kernel.html +329 -329
- data/doc/rdoc/core/classes/Lazy/Promise.html +1 -1
- data/doc/rdoc/core/classes/MatchData.html +15 -15
- data/doc/rdoc/core/classes/Module.html +176 -157
- data/doc/rdoc/core/classes/NilClass.html +23 -23
- data/doc/rdoc/core/classes/Numeric.html +27 -27
- data/doc/rdoc/core/classes/Object.html +8 -8
- data/doc/rdoc/core/classes/ObjectSpace.html +5 -5
- data/doc/rdoc/core/classes/Proc.html +22 -22
- data/doc/rdoc/core/classes/Regexp.html +1 -1
- data/doc/rdoc/core/classes/Stackable.html +31 -31
- data/doc/rdoc/core/classes/String.html +332 -291
- data/doc/rdoc/core/classes/Symbol.html +1 -1
- data/doc/rdoc/core/classes/TrueClass.html +8 -8
- data/doc/rdoc/core/classes/UnboundMethod.html +18 -13
- data/doc/rdoc/core/created.rid +1 -1
- data/doc/rdoc/core/files/README.html +7 -29
- data/doc/rdoc/core/files/lib/core/facets/array/product_rb.html +1 -1
- data/doc/rdoc/core/files/lib/core/facets/enumerable/collect_rb.html +10 -1
- data/doc/rdoc/core/files/lib/core/facets/enumerable/compact_map_rb.html +92 -0
- data/doc/rdoc/core/files/lib/core/facets/enumerable/map_with_index_rb.html +92 -0
- data/doc/rdoc/core/files/lib/core/facets/enumerable/split_rb.html +1 -1
- data/doc/rdoc/core/files/lib/core/facets/hash/collate_rb.html +1 -1
- data/doc/rdoc/core/files/lib/core/facets/hash/group_by_value_rb.html +92 -0
- data/doc/rdoc/core/files/lib/core/facets/hash/new_with_rb.html +92 -0
- data/doc/rdoc/core/files/lib/core/facets/module/conflict_rb.html +1 -1
- data/doc/rdoc/core/files/lib/core/facets/module/extend_rb.html +92 -0
- data/doc/rdoc/core/files/lib/core/facets/string/align_rb.html +1 -1
- data/doc/rdoc/core/files/lib/core/facets/string/file_rb.html +96 -0
- data/doc/rdoc/core/files/lib/core/facets/string/xor_rb.html +1 -1
- data/doc/rdoc/core/files/lib/core/facets/to_hash_rb.html +5 -1
- data/doc/rdoc/core/files/lib/core/facets/unboundmethod/name_rb.html +1 -1
- data/doc/rdoc/core/fr_class_index.html +2 -0
- data/doc/rdoc/core/fr_file_index.html +6 -0
- data/doc/rdoc/core/fr_method_index.html +386 -373
- data/doc/rdoc/lore/classes/OpenStruct.html +6 -4
- data/doc/rdoc/lore/created.rid +1 -1
- data/doc/rdoc/lore/files/README.html +7 -29
- data/doc/rdoc/lore/files/lib/lore/facets/ostruct_rb.html +1 -1
- data/doc/rdoc/more/classes/ANSICode.html +66 -66
- data/doc/rdoc/more/classes/Advisable.html +37 -37
- data/doc/rdoc/more/classes/Advisable/Method.html +20 -20
- data/doc/rdoc/more/classes/Archive/Tar/Minitar.html +27 -27
- data/doc/rdoc/more/classes/Archive/Tar/Minitar/Input.html +28 -28
- data/doc/rdoc/more/classes/Archive/Tar/Minitar/Output.html +19 -19
- data/doc/rdoc/more/classes/Archive/Tar/Minitar/Reader.html +31 -31
- data/doc/rdoc/more/classes/Archive/Tar/Minitar/Writer.html +33 -33
- data/doc/rdoc/more/classes/Association.html +67 -53
- data/doc/rdoc/more/classes/Association/Kernel.html +11 -12
- data/doc/rdoc/more/classes/BBCode.html +36 -36
- data/doc/rdoc/more/classes/BaseX.html +16 -16
- data/doc/rdoc/more/classes/BiCrypt.html +67 -67
- data/doc/rdoc/more/classes/BinReadable.html +85 -85
- data/doc/rdoc/more/classes/BinReadable/ByteOrder.html +25 -25
- data/doc/rdoc/more/classes/Binding.html +8 -8
- data/doc/rdoc/more/classes/Buildable.html +4 -4
- data/doc/rdoc/more/classes/Cloneable.html +4 -4
- data/doc/rdoc/more/classes/ConsoleUtils.html +18 -18
- data/doc/rdoc/more/classes/Crypt.html +16 -16
- data/doc/rdoc/more/classes/CssTree.html +8 -8
- data/doc/rdoc/more/classes/Dictionary.html +52 -45
- data/doc/rdoc/more/classes/Enumerable.html +50 -50
- data/doc/rdoc/more/classes/Enumerable/Elementor.html +16 -16
- data/doc/rdoc/more/classes/Enumerable/Enumerator.html +4 -4
- data/doc/rdoc/more/classes/Enumerable/Filterable.html +30 -30
- data/doc/rdoc/more/classes/EnumerablePass.html +15 -15
- data/doc/rdoc/more/classes/Equatable.html +16 -16
- data/doc/rdoc/more/classes/Expirable.html +17 -17
- data/doc/rdoc/more/classes/Fileable.html +14 -14
- data/doc/rdoc/more/classes/Fileable/DSL.html +41 -41
- data/doc/rdoc/more/classes/Hash2Xml.html +4 -4
- data/doc/rdoc/more/classes/Hook.html +162 -0
- data/doc/rdoc/more/classes/HtmlFilter.html +9 -9
- data/doc/rdoc/more/classes/Instantiable.html +9 -9
- data/doc/rdoc/more/classes/Instantize.html +8 -8
- data/doc/rdoc/more/classes/Interval.html +187 -187
- data/doc/rdoc/more/classes/It.html +12 -12
- data/doc/rdoc/more/classes/Matcher.html +38 -38
- data/doc/rdoc/more/classes/Matcher/MatchData.html +4 -4
- data/doc/rdoc/more/classes/Memoizer.html +21 -21
- data/doc/rdoc/more/classes/Multiton.html +12 -12
- data/doc/rdoc/more/classes/Multiton/MetaMethods.html +28 -28
- data/doc/rdoc/more/classes/Net/SMTP.html +8 -8
- data/doc/rdoc/more/classes/OpEsc.html +5 -5
- data/doc/rdoc/more/classes/OpenCascade.html +4 -4
- data/doc/rdoc/more/classes/OpenHash.html +9 -9
- data/doc/rdoc/more/classes/OpenStructable.html +36 -36
- data/doc/rdoc/more/classes/PQueue.html +84 -84
- data/doc/rdoc/more/classes/Paramix.html +16 -16
- data/doc/rdoc/more/classes/Paramix/Delegator.html +16 -16
- data/doc/rdoc/more/classes/RWDelegator.html +16 -16
- data/doc/rdoc/more/classes/Random.html +5 -5
- data/doc/rdoc/more/classes/Random/Array.html +37 -37
- data/doc/rdoc/more/classes/Random/Hash.html +52 -52
- data/doc/rdoc/more/classes/Random/Object.html +4 -4
- data/doc/rdoc/more/classes/Random/String.html +34 -34
- data/doc/rdoc/more/classes/Random/String/Self.html +9 -9
- data/doc/rdoc/more/classes/Registerable.html +13 -13
- data/doc/rdoc/more/classes/Stash.html +28 -28
- data/doc/rdoc/more/classes/String/Mask.html +72 -72
- data/doc/rdoc/more/classes/String/Words.html +31 -31
- data/doc/rdoc/more/classes/System.html +253 -253
- data/doc/rdoc/more/classes/Timer.html +48 -48
- data/doc/rdoc/more/classes/Timer/Dummy.html +9 -9
- data/doc/rdoc/more/classes/Tuple.html +170 -170
- data/doc/rdoc/more/classes/TypeCast/Class.html +4 -4
- data/doc/rdoc/more/classes/TypeCast/Object.html +4 -4
- data/doc/rdoc/more/classes/Uninheritable.html +6 -6
- data/doc/rdoc/more/classes/X.html +117 -0
- data/doc/rdoc/more/classes/XOXO.html +11 -11
- data/doc/rdoc/more/classes/ZipUtils.html +88 -88
- data/doc/rdoc/more/classes/ZipUtils/DryRun.html +68 -68
- data/doc/rdoc/more/classes/ZipUtils/NoWrite.html +68 -68
- data/doc/rdoc/more/classes/ZipUtils/Verbose.html +60 -60
- data/doc/rdoc/more/created.rid +1 -1
- data/doc/rdoc/more/files/README.html +7 -29
- data/doc/rdoc/more/files/lib/more/facets/association_rb.html +1 -1
- data/doc/rdoc/more/files/lib/more/facets/dictionary_rb.html +1 -1
- data/doc/rdoc/more/files/lib/more/facets/hook_rb.html +96 -0
- data/doc/rdoc/more/files/lib/more/facets/paramix_rb.html +1 -1
- data/doc/rdoc/more/files/lib/more/facets/xoxo_rb.html +2 -2
- data/doc/rdoc/more/fr_class_index.html +2 -0
- data/doc/rdoc/more/fr_file_index.html +1 -0
- data/doc/rdoc/more/fr_method_index.html +686 -681
- data/lib/core/facets/array/product.rb +6 -23
- data/lib/core/facets/enumerable/collect.rb +3 -53
- data/lib/core/facets/enumerable/compact_map.rb +35 -0
- data/lib/core/facets/enumerable/map_with_index.rb +23 -0
- data/lib/core/facets/enumerable/split.rb +3 -3
- data/lib/core/facets/hash/collate.rb +45 -14
- data/lib/core/facets/hash/group_by_value.rb +65 -0
- data/lib/core/facets/hash/new_with.rb +15 -0
- data/lib/core/facets/module/extend.rb +11 -0
- data/lib/core/facets/string/align.rb +19 -18
- data/lib/core/facets/string/file.rb +17 -0
- data/lib/core/facets/string/xor.rb +9 -3
- data/lib/core/facets/to_hash.rb +274 -17
- data/lib/core/facets/unboundmethod/name.rb +4 -2
- data/lib/lore/facets/ostruct.rb +3 -0
- data/lib/more/facets/association.rb +28 -12
- data/lib/more/facets/dictionary.rb +10 -4
- data/lib/more/facets/hook.rb +65 -0
- data/lib/more/facets/paramix.rb +5 -5
- data/meta/abstract +13 -0
- data/meta/authors +1 -0
- data/meta/contact +1 -0
- data/meta/contributors +48 -0
- data/meta/created +1 -0
- data/meta/homepage +1 -0
- data/meta/license +1 -0
- data/meta/loadpath +3 -0
- data/meta/releases +14 -0
- data/meta/slogan +1 -0
- data/meta/summary +1 -0
- data/task/test.rake +116 -18
- data/test/core/array/test_product.rb +0 -6
- data/test/core/binding/test_local_variables.rb +9 -3
- data/test/core/enumerable/test_split.rb +19 -0
- data/test/core/module/test_conflict.rb +8 -3
- data/test/core/test_to_hash.rb +152 -0
- data/test/core/unboundmethod/test_arguments.rb +1 -1
- data/test/core/unboundmethod/test_name.rb +2 -2
- metadata +39 -8
- data/doc/log/bstats/stats.html +0 -39
- data/doc/log/stats.html +0 -25
- data/test/more/test_to_hash.rb +0 -58
@@ -102,30 +102,35 @@ Object
|
|
102
102
|
|
103
103
|
|
104
104
|
<div class="sectiontitle">Methods</div>
|
105
|
-
<span style="padding-right: 5px;"><a href="#
|
106
|
-
<span style="padding-right: 5px;"><a href="#
|
107
|
-
<span style="padding-right: 5px;"><a href="#
|
108
|
-
<span style="padding-right: 5px;"><a href="#
|
109
|
-
<span style="padding-right: 5px;"><a href="#
|
110
|
-
<span style="padding-right: 5px;"><a href="#
|
111
|
-
<span style="padding-right: 5px;"><a href="#
|
112
|
-
<span style="padding-right: 5px;"><a href="#
|
113
|
-
<span style="padding-right: 5px;"><a href="#
|
114
|
-
<span style="padding-right: 5px;"><a href="#
|
115
|
-
<span style="padding-right: 5px;"><a href="#
|
116
|
-
<span style="padding-right: 5px;"><a href="#
|
117
|
-
<span style="padding-right: 5px;"><a href="#
|
118
|
-
<span style="padding-right: 5px;"><a href="#
|
119
|
-
<span style="padding-right: 5px;"><a href="#
|
120
|
-
<span style="padding-right: 5px;"><a href="#
|
121
|
-
<span style="padding-right: 5px;"><a href="#
|
122
|
-
<span style="padding-right: 5px;"><a href="#
|
123
|
-
<span style="padding-right: 5px;"><a href="#
|
124
|
-
<span style="padding-right: 5px;"><a href="#
|
125
|
-
<span style="padding-right: 5px;"><a href="#
|
126
|
-
<span style="padding-right: 5px;"><a href="#
|
127
|
-
<span style="padding-right: 5px;"><a href="#
|
128
|
-
<span style="padding-right: 5px;"><a href="#
|
105
|
+
<span style="padding-right: 5px;"><a href="#M000083">**</a></span>
|
106
|
+
<span style="padding-right: 5px;"><a href="#M000098">combination</a></span>
|
107
|
+
<span style="padding-right: 5px;"><a href="#M000090">conjoin</a></span>
|
108
|
+
<span style="padding-right: 5px;"><a href="#M000087">delete_unless</a></span>
|
109
|
+
<span style="padding-right: 5px;"><a href="#M000099">delete_values</a></span>
|
110
|
+
<span style="padding-right: 5px;"><a href="#M000100">delete_values_at</a></span>
|
111
|
+
<span style="padding-right: 5px;"><a href="#M000096">index</a></span>
|
112
|
+
<span style="padding-right: 5px;"><a href="#M000091">merge!</a></span>
|
113
|
+
<span style="padding-right: 5px;"><a href="#M000086">not_empty?</a></span>
|
114
|
+
<span style="padding-right: 5px;"><a href="#M000097">only</a></span>
|
115
|
+
<span style="padding-right: 5px;"><a href="#M000102">pad</a></span>
|
116
|
+
<span style="padding-right: 5px;"><a href="#M000103">pad!</a></span>
|
117
|
+
<span style="padding-right: 5px;"><a href="#M000094">permutation</a></span>
|
118
|
+
<span style="padding-right: 5px;"><a href="#M000082">product</a></span>
|
119
|
+
<span style="padding-right: 5px;"><a href="#M000084">recursively</a></span>
|
120
|
+
<span style="padding-right: 5px;"><a href="#M000085">recursively!</a></span>
|
121
|
+
<span style="padding-right: 5px;"><a href="#M000088">rotate</a></span>
|
122
|
+
<span style="padding-right: 5px;"><a href="#M000089">rotate!</a></span>
|
123
|
+
<span style="padding-right: 5px;"><a href="#M000095">select!</a></span>
|
124
|
+
<span style="padding-right: 5px;"><a href="#M000101">splice</a></span>
|
125
|
+
<span style="padding-right: 5px;"><a href="#M000081">to_b</a></span>
|
126
|
+
<span style="padding-right: 5px;"><a href="#M000075">to_h</a></span>
|
127
|
+
<span style="padding-right: 5px;"><a href="#M000079">to_h_assoc</a></span>
|
128
|
+
<span style="padding-right: 5px;"><a href="#M000076">to_h_auto</a></span>
|
129
|
+
<span style="padding-right: 5px;"><a href="#M000078">to_h_flat</a></span>
|
130
|
+
<span style="padding-right: 5px;"><a href="#M000080">to_h_multi</a></span>
|
131
|
+
<span style="padding-right: 5px;"><a href="#M000077">to_h_splat</a></span>
|
132
|
+
<span style="padding-right: 5px;"><a href="#M000092">traverse</a></span>
|
133
|
+
<span style="padding-right: 5px;"><a href="#M000093">traverse!</a></span>
|
129
134
|
|
130
135
|
<div class="sectiontitle">Included Modules</div>
|
131
136
|
<ul>
|
@@ -140,22 +145,22 @@ Object
|
|
140
145
|
<div class="sectiontitle">Public Instance methods</div>
|
141
146
|
<div class="method">
|
142
147
|
<div class="title">
|
143
|
-
<a name="
|
148
|
+
<a name="M000083"></a><b>**</b>(*enums)
|
144
149
|
</div>
|
145
150
|
<div class="description">
|
146
151
|
<p>
|
147
|
-
Alias for <a href="Array.html#
|
152
|
+
Alias for <a href="Array.html#M000082">product</a>
|
148
153
|
</p>
|
149
154
|
</div>
|
150
155
|
</div>
|
151
156
|
<div class="method">
|
152
157
|
<div class="title">
|
153
|
-
<a name="
|
158
|
+
<a name="M000098"></a><b>combination</b>(k=2) {|s.values_at(*idx)| ...}
|
154
159
|
</div>
|
155
160
|
<div class="description">
|
156
161
|
<p>
|
157
162
|
Yields the block to each unique <a
|
158
|
-
href="Array.html#
|
163
|
+
href="Array.html#M000098">combination</a> of <em>n</em> elements.
|
159
164
|
</p>
|
160
165
|
<pre>
|
161
166
|
a = %w|a b c d|
|
@@ -175,8 +180,8 @@ CREDIT: Florian Gross
|
|
175
180
|
</p>
|
176
181
|
</div>
|
177
182
|
<div class="sourcecode">
|
178
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
179
|
-
<div id="
|
183
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000098_source')" id="l_M000098_source">+</a> ]</p>
|
184
|
+
<div id="M000098_source" class="dyn-source">
|
180
185
|
<pre>
|
181
186
|
<span class="ruby-comment cmt"># File lib/core/facets/array/combination.rb, line 21</span>
|
182
187
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">combination</span>(<span class="ruby-identifier">k</span>=<span class="ruby-value">2</span>)
|
@@ -203,7 +208,7 @@ CREDIT: Florian Gross
|
|
203
208
|
</div>
|
204
209
|
<div class="method">
|
205
210
|
<div class="title">
|
206
|
-
<a name="
|
211
|
+
<a name="M000090"></a><b>conjoin</b>(*args) {|i, *slice(i,2)| ...}
|
207
212
|
</div>
|
208
213
|
<div class="description">
|
209
214
|
<p>
|
@@ -239,8 +244,8 @@ CREDIT: Trans
|
|
239
244
|
</p>
|
240
245
|
</div>
|
241
246
|
<div class="sourcecode">
|
242
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
243
|
-
<div id="
|
247
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000090_source')" id="l_M000090_source">+</a> ]</p>
|
248
|
+
<div id="M000090_source" class="dyn-source">
|
244
249
|
<pre>
|
245
250
|
<span class="ruby-comment cmt"># File lib/core/facets/array/conjoin.rb, line 30</span>
|
246
251
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">conjoin</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
@@ -275,7 +280,7 @@ CREDIT: Trans
|
|
275
280
|
</div>
|
276
281
|
<div class="method">
|
277
282
|
<div class="title">
|
278
|
-
<a name="
|
283
|
+
<a name="M000087"></a><b>delete_unless</b>(&block)
|
279
284
|
</div>
|
280
285
|
<div class="description">
|
281
286
|
<p>
|
@@ -290,8 +295,8 @@ CREDIT: Daniel Schierbeck
|
|
290
295
|
</p>
|
291
296
|
</div>
|
292
297
|
<div class="sourcecode">
|
293
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
294
|
-
<div id="
|
298
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000087_source')" id="l_M000087_source">+</a> ]</p>
|
299
|
+
<div id="M000087_source" class="dyn-source">
|
295
300
|
<pre>
|
296
301
|
<span class="ruby-comment cmt"># File lib/core/facets/array/delete_unless.rb, line 10</span>
|
297
302
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_unless</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
@@ -303,7 +308,7 @@ CREDIT: Daniel Schierbeck
|
|
303
308
|
</div>
|
304
309
|
<div class="method">
|
305
310
|
<div class="title">
|
306
|
-
<a name="
|
311
|
+
<a name="M000099"></a><b>delete_values</b>(*values)
|
307
312
|
</div>
|
308
313
|
<div class="description">
|
309
314
|
<p>
|
@@ -319,8 +324,8 @@ CREDIT: Trans
|
|
319
324
|
</p>
|
320
325
|
</div>
|
321
326
|
<div class="sourcecode">
|
322
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
323
|
-
<div id="
|
327
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000099_source')" id="l_M000099_source">+</a> ]</p>
|
328
|
+
<div id="M000099_source" class="dyn-source">
|
324
329
|
<pre>
|
325
330
|
<span class="ruby-comment cmt"># File lib/core/facets/array/delete_values.rb, line 11</span>
|
326
331
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_values</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">values</span>)
|
@@ -334,12 +339,12 @@ CREDIT: Trans
|
|
334
339
|
</div>
|
335
340
|
<div class="method">
|
336
341
|
<div class="title">
|
337
|
-
<a name="
|
342
|
+
<a name="M000100"></a><b>delete_values_at</b>(*selectors)
|
338
343
|
</div>
|
339
344
|
<div class="description">
|
340
345
|
<p>
|
341
346
|
Delete multiple values from array given indexes or <a
|
342
|
-
href="Array.html#
|
347
|
+
href="Array.html#M000096">index</a> range.
|
343
348
|
</p>
|
344
349
|
<pre>
|
345
350
|
a = [1,2,3,4]
|
@@ -357,8 +362,8 @@ CREDIT: Trans
|
|
357
362
|
</p>
|
358
363
|
</div>
|
359
364
|
<div class="sourcecode">
|
360
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
361
|
-
<div id="
|
365
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000100_source')" id="l_M000100_source">+</a> ]</p>
|
366
|
+
<div id="M000100_source" class="dyn-source">
|
362
367
|
<pre>
|
363
368
|
<span class="ruby-comment cmt"># File lib/core/facets/array/delete_values.rb, line 32</span>
|
364
369
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_values_at</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">selectors</span>)
|
@@ -383,19 +388,19 @@ CREDIT: Trans
|
|
383
388
|
</div>
|
384
389
|
<div class="method">
|
385
390
|
<div class="title">
|
386
|
-
<a name="
|
391
|
+
<a name="M000096"></a><b>index</b>(obj=nil, &block)
|
387
392
|
</div>
|
388
393
|
<div class="description">
|
389
394
|
<p>
|
390
|
-
Allows <a href="Array.html#
|
395
|
+
Allows <a href="Array.html#M000096">index</a> to accept a block.
|
391
396
|
</p>
|
392
397
|
<p>
|
393
398
|
OVERRIDE! This is one of the bery few core overrides in Facets.
|
394
399
|
</p>
|
395
400
|
</div>
|
396
401
|
<div class="sourcecode">
|
397
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
398
|
-
<div id="
|
402
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000096_source')" id="l_M000096_source">+</a> ]</p>
|
403
|
+
<div id="M000096_source" class="dyn-source">
|
399
404
|
<pre>
|
400
405
|
<span class="ruby-comment cmt"># File lib/core/facets/array/index.rb, line 12</span>
|
401
406
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">index</span>(<span class="ruby-identifier">obj</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
@@ -411,7 +416,7 @@ OVERRIDE! This is one of the bery few core overrides in Facets.
|
|
411
416
|
</div>
|
412
417
|
<div class="method">
|
413
418
|
<div class="title">
|
414
|
-
<a name="
|
419
|
+
<a name="M000091"></a><b>merge!</b>( other )
|
415
420
|
</div>
|
416
421
|
<div class="description">
|
417
422
|
<p>
|
@@ -427,8 +432,8 @@ CREDIT: Trans
|
|
427
432
|
</p>
|
428
433
|
</div>
|
429
434
|
<div class="sourcecode">
|
430
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
431
|
-
<div id="
|
435
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000091_source')" id="l_M000091_source">+</a> ]</p>
|
436
|
+
<div id="M000091_source" class="dyn-source">
|
432
437
|
<pre>
|
433
438
|
<span class="ruby-comment cmt"># File lib/core/facets/array/merge.rb, line 11</span>
|
434
439
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge!</span>( <span class="ruby-identifier">other</span> )
|
@@ -440,7 +445,7 @@ CREDIT: Trans
|
|
440
445
|
</div>
|
441
446
|
<div class="method">
|
442
447
|
<div class="title">
|
443
|
-
<a name="
|
448
|
+
<a name="M000086"></a><b>not_empty?</b>()
|
444
449
|
</div>
|
445
450
|
<div class="description">
|
446
451
|
<p>
|
@@ -452,8 +457,8 @@ Not empty?
|
|
452
457
|
</pre>
|
453
458
|
</div>
|
454
459
|
<div class="sourcecode">
|
455
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
456
|
-
<div id="
|
460
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000086_source')" id="l_M000086_source">+</a> ]</p>
|
461
|
+
<div id="M000086_source" class="dyn-source">
|
457
462
|
<pre>
|
458
463
|
<span class="ruby-comment cmt"># File lib/core/facets/array/not_empty.rb, line 8</span>
|
459
464
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">not_empty?</span>
|
@@ -465,11 +470,11 @@ Not empty?
|
|
465
470
|
</div>
|
466
471
|
<div class="method">
|
467
472
|
<div class="title">
|
468
|
-
<a name="
|
473
|
+
<a name="M000097"></a><b>only</b>()
|
469
474
|
</div>
|
470
475
|
<div class="description">
|
471
476
|
<p>
|
472
|
-
Returns the <em><a href="Array.html#
|
477
|
+
Returns the <em><a href="Array.html#M000097">only</a></em> element in the
|
473
478
|
array. Raises an IndexError if the array‘s size is not 1.
|
474
479
|
</p>
|
475
480
|
<pre>
|
@@ -482,8 +487,8 @@ CREDIT: Gavin Sinclair, Noah Gibbs
|
|
482
487
|
</p>
|
483
488
|
</div>
|
484
489
|
<div class="sourcecode">
|
485
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
486
|
-
<div id="
|
490
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000097_source')" id="l_M000097_source">+</a> ]</p>
|
491
|
+
<div id="M000097_source" class="dyn-source">
|
487
492
|
<pre>
|
488
493
|
<span class="ruby-comment cmt"># File lib/core/facets/array/only.rb, line 12</span>
|
489
494
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">only</span>
|
@@ -498,7 +503,7 @@ CREDIT: Gavin Sinclair, Noah Gibbs
|
|
498
503
|
</div>
|
499
504
|
<div class="method">
|
500
505
|
<div class="title">
|
501
|
-
<a name="
|
506
|
+
<a name="M000102"></a><b>pad</b>(len, val=nil)
|
502
507
|
</div>
|
503
508
|
<div class="description">
|
504
509
|
<p>
|
@@ -519,8 +524,8 @@ CREDIT: Richard Laugesen
|
|
519
524
|
</p>
|
520
525
|
</div>
|
521
526
|
<div class="sourcecode">
|
522
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
523
|
-
<div id="
|
527
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000102_source')" id="l_M000102_source">+</a> ]</p>
|
528
|
+
<div id="M000102_source" class="dyn-source">
|
524
529
|
<pre>
|
525
530
|
<span class="ruby-comment cmt"># File lib/core/facets/array/pad.rb, line 14</span>
|
526
531
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pad</span>(<span class="ruby-identifier">len</span>, <span class="ruby-identifier">val</span>=<span class="ruby-keyword kw">nil</span>)
|
@@ -537,11 +542,11 @@ CREDIT: Richard Laugesen
|
|
537
542
|
</div>
|
538
543
|
<div class="method">
|
539
544
|
<div class="title">
|
540
|
-
<a name="
|
545
|
+
<a name="M000103"></a><b>pad!</b>(len, val=nil)
|
541
546
|
</div>
|
542
547
|
<div class="description">
|
543
548
|
<p>
|
544
|
-
Like <a href="Array.html#
|
549
|
+
Like <a href="Array.html#M000102">pad</a> but changes the array in place.
|
545
550
|
</p>
|
546
551
|
<pre>
|
547
552
|
a = [0,1,2]
|
@@ -553,8 +558,8 @@ CREDIT: Richard Laugesen
|
|
553
558
|
</p>
|
554
559
|
</div>
|
555
560
|
<div class="sourcecode">
|
556
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
557
|
-
<div id="
|
561
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000103_source')" id="l_M000103_source">+</a> ]</p>
|
562
|
+
<div id="M000103_source" class="dyn-source">
|
558
563
|
<pre>
|
559
564
|
<span class="ruby-comment cmt"># File lib/core/facets/array/pad.rb, line 31</span>
|
560
565
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pad!</span>(<span class="ruby-identifier">len</span>, <span class="ruby-identifier">val</span>=<span class="ruby-keyword kw">nil</span>)
|
@@ -571,12 +576,12 @@ CREDIT: Richard Laugesen
|
|
571
576
|
</div>
|
572
577
|
<div class="method">
|
573
578
|
<div class="title">
|
574
|
-
<a name="
|
579
|
+
<a name="M000094"></a><b>permutation</b>(n=size) {|[]| ...}
|
575
580
|
</div>
|
576
581
|
<div class="description">
|
577
582
|
<p>
|
578
583
|
Permutation provids the possible orders of an enumerable. Each is indexed
|
579
|
-
by a <a href="Array.html#
|
584
|
+
by a <a href="Array.html#M000094">permutation</a> number. The maximum
|
580
585
|
number of arrangements is the factorial of the size of the array.
|
581
586
|
</p>
|
582
587
|
<p>
|
@@ -584,8 +589,8 @@ CREDIT: Shin-ichiro Hara
|
|
584
589
|
</p>
|
585
590
|
</div>
|
586
591
|
<div class="sourcecode">
|
587
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
588
|
-
<div id="
|
592
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000094_source')" id="l_M000094_source">+</a> ]</p>
|
593
|
+
<div id="M000094_source" class="dyn-source">
|
589
594
|
<pre>
|
590
595
|
<span class="ruby-comment cmt"># File lib/core/facets/array/permutation.rb, line 11</span>
|
591
596
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">permutation</span>(<span class="ruby-identifier">n</span>=<span class="ruby-identifier">size</span>)
|
@@ -609,23 +614,16 @@ CREDIT: Shin-ichiro Hara
|
|
609
614
|
</div>
|
610
615
|
<div class="method">
|
611
616
|
<div class="title">
|
612
|
-
<a name="
|
617
|
+
<a name="M000082"></a><b>product</b>(*enums)
|
613
618
|
</div>
|
614
619
|
<div class="description">
|
615
620
|
<p>
|
616
|
-
Provides the
|
617
|
-
|
618
|
-
this.
|
621
|
+
Provides the cartesian <a href="Array.html#M000082">product</a> of two or
|
622
|
+
more arrays.
|
619
623
|
</p>
|
620
624
|
<pre>
|
621
|
-
Enumerable.cartesian_product([1,2], [4], ["apple", "banana"])
|
622
|
-
#=> [[1, 4, "apple"], [1, 4, "banana"], [2, 4, "apple"], [2, 4, "banana"]]
|
623
|
-
|
624
|
-
Enumerable.cartesian_product([1,2], [3,4])
|
625
|
-
#=> [[1, 3], [1, 4], [2, 3], [2, 4]]
|
626
|
-
|
627
625
|
a = []
|
628
|
-
[1,2].
|
626
|
+
[1,2].product([4,5])
|
629
627
|
a #=> [[1, 4],[1, 5],[2, 4],[2, 5]]
|
630
628
|
</pre>
|
631
629
|
<p>
|
@@ -634,14 +632,14 @@ CREDIT: Thomas Hafner
|
|
634
632
|
</div>
|
635
633
|
<div class="aka">
|
636
634
|
This method is also aliased as
|
637
|
-
<a href="Array.html#
|
635
|
+
<a href="Array.html#M000083">**</a>
|
638
636
|
</div>
|
639
637
|
<div class="sourcecode">
|
640
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
641
|
-
<div id="
|
638
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000082_source')" id="l_M000082_source">+</a> ]</p>
|
639
|
+
<div id="M000082_source" class="dyn-source">
|
642
640
|
<pre>
|
643
|
-
<span class="ruby-comment cmt"># File lib/core/facets/array/product.rb, line
|
644
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">product</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">enums</span
|
641
|
+
<span class="ruby-comment cmt"># File lib/core/facets/array/product.rb, line 13</span>
|
642
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">product</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">enums</span>)
|
645
643
|
<span class="ruby-identifier">enums</span>.<span class="ruby-identifier">unshift</span> <span class="ruby-keyword kw">self</span>
|
646
644
|
<span class="ruby-identifier">result</span> = [[]]
|
647
645
|
<span class="ruby-keyword kw">while</span> [] <span class="ruby-operator">!=</span> <span class="ruby-identifier">enums</span>
|
@@ -653,11 +651,7 @@ CREDIT: Thomas Hafner
|
|
653
651
|
<span class="ruby-keyword kw">end</span>
|
654
652
|
<span class="ruby-keyword kw">end</span>
|
655
653
|
<span class="ruby-keyword kw">end</span>
|
656
|
-
<span class="ruby-
|
657
|
-
<span class="ruby-identifier">result</span>.<span class="ruby-identifier">each</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">e</span>) }
|
658
|
-
<span class="ruby-keyword kw">else</span>
|
659
|
-
<span class="ruby-identifier">result</span>
|
660
|
-
<span class="ruby-keyword kw">end</span>
|
654
|
+
<span class="ruby-identifier">result</span>
|
661
655
|
<span class="ruby-keyword kw">end</span>
|
662
656
|
</pre>
|
663
657
|
</div>
|
@@ -665,11 +659,11 @@ CREDIT: Thomas Hafner
|
|
665
659
|
</div>
|
666
660
|
<div class="method">
|
667
661
|
<div class="title">
|
668
|
-
<a name="
|
662
|
+
<a name="M000084"></a><b>recursively</b>() {|a| ...}
|
669
663
|
</div>
|
670
664
|
<div class="description">
|
671
665
|
<p>
|
672
|
-
Apply a block to hash, and <a href="Array.html#
|
666
|
+
Apply a block to hash, and <a href="Array.html#M000084">recursively</a>
|
673
667
|
apply that block to each subhash.
|
674
668
|
</p>
|
675
669
|
<pre>
|
@@ -682,8 +676,8 @@ TODO: Can this be generalized in Enumerbale?
|
|
682
676
|
</p>
|
683
677
|
</div>
|
684
678
|
<div class="sourcecode">
|
685
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
686
|
-
<div id="
|
679
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000084_source')" id="l_M000084_source">+</a> ]</p>
|
680
|
+
<div id="M000084_source" class="dyn-source">
|
687
681
|
<pre>
|
688
682
|
<span class="ruby-comment cmt"># File lib/core/facets/array/recursively.rb, line 12</span>
|
689
683
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recursively</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
@@ -703,16 +697,16 @@ TODO: Can this be generalized in Enumerbale?
|
|
703
697
|
</div>
|
704
698
|
<div class="method">
|
705
699
|
<div class="title">
|
706
|
-
<a name="
|
700
|
+
<a name="M000085"></a><b>recursively!</b>(&block)
|
707
701
|
</div>
|
708
702
|
<div class="description">
|
709
703
|
<p>
|
710
|
-
In place form of <a href="Array.html#
|
704
|
+
In place form of <a href="Array.html#M000084">recursively</a>.
|
711
705
|
</p>
|
712
706
|
</div>
|
713
707
|
<div class="sourcecode">
|
714
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
715
|
-
<div id="
|
708
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000085_source')" id="l_M000085_source">+</a> ]</p>
|
709
|
+
<div id="M000085_source" class="dyn-source">
|
716
710
|
<pre>
|
717
711
|
<span class="ruby-comment cmt"># File lib/core/facets/array/recursively.rb, line 26</span>
|
718
712
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recursively!</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
@@ -724,7 +718,7 @@ In place form of <a href="Array.html#M000135">recursively</a>.
|
|
724
718
|
</div>
|
725
719
|
<div class="method">
|
726
720
|
<div class="title">
|
727
|
-
<a name="
|
721
|
+
<a name="M000088"></a><b>rotate</b>(n=1)
|
728
722
|
</div>
|
729
723
|
<div class="description">
|
730
724
|
<p>
|
@@ -747,8 +741,8 @@ CREDIT: Florian Gross, Thomas Sawyer
|
|
747
741
|
</p>
|
748
742
|
</div>
|
749
743
|
<div class="sourcecode">
|
750
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
751
|
-
<div id="
|
744
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000088_source')" id="l_M000088_source">+</a> ]</p>
|
745
|
+
<div id="M000088_source" class="dyn-source">
|
752
746
|
<pre>
|
753
747
|
<span class="ruby-comment cmt"># File lib/core/facets/array/rotate.rb, line 16</span>
|
754
748
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rotate</span>(<span class="ruby-identifier">n</span>=<span class="ruby-value">1</span>)
|
@@ -760,11 +754,11 @@ CREDIT: Florian Gross, Thomas Sawyer
|
|
760
754
|
</div>
|
761
755
|
<div class="method">
|
762
756
|
<div class="title">
|
763
|
-
<a name="
|
757
|
+
<a name="M000089"></a><b>rotate!</b>(n=1)
|
764
758
|
</div>
|
765
759
|
<div class="description">
|
766
760
|
<p>
|
767
|
-
Same as <a href="Array.html#
|
761
|
+
Same as <a href="Array.html#M000088">rotate</a>, but acts in place.
|
768
762
|
</p>
|
769
763
|
<pre>
|
770
764
|
a = [1,2,3]
|
@@ -776,8 +770,8 @@ CREDIT: Florian Gross, Thomas Sawyer
|
|
776
770
|
</p>
|
777
771
|
</div>
|
778
772
|
<div class="sourcecode">
|
779
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
780
|
-
<div id="
|
773
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000089_source')" id="l_M000089_source">+</a> ]</p>
|
774
|
+
<div id="M000089_source" class="dyn-source">
|
781
775
|
<pre>
|
782
776
|
<span class="ruby-comment cmt"># File lib/core/facets/array/rotate.rb, line 28</span>
|
783
777
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rotate!</span>(<span class="ruby-identifier">n</span>=<span class="ruby-value">1</span>)
|
@@ -796,7 +790,7 @@ CREDIT: Florian Gross, Thomas Sawyer
|
|
796
790
|
</div>
|
797
791
|
<div class="method">
|
798
792
|
<div class="title">
|
799
|
-
<a name="
|
793
|
+
<a name="M000095"></a><b>select!</b>( {|| ...}
|
800
794
|
</div>
|
801
795
|
<div class="description">
|
802
796
|
<p>
|
@@ -812,8 +806,8 @@ CREDIT: Gavin Sinclair
|
|
812
806
|
</p>
|
813
807
|
</div>
|
814
808
|
<div class="sourcecode">
|
815
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
816
|
-
<div id="
|
809
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000095_source')" id="l_M000095_source">+</a> ]</p>
|
810
|
+
<div id="M000095_source" class="dyn-source">
|
817
811
|
<pre>
|
818
812
|
<span class="ruby-comment cmt"># File lib/core/facets/array/select.rb, line 11</span>
|
819
813
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select!</span> <span class="ruby-comment cmt"># :yield:</span>
|
@@ -825,11 +819,11 @@ CREDIT: Gavin Sinclair
|
|
825
819
|
</div>
|
826
820
|
<div class="method">
|
827
821
|
<div class="title">
|
828
|
-
<a name="
|
822
|
+
<a name="M000101"></a><b>splice</b>(*args)
|
829
823
|
</div>
|
830
824
|
<div class="description">
|
831
825
|
<p>
|
832
|
-
Splice acts a <a href="Array.html#
|
826
|
+
Splice acts a <a href="Array.html#M000098">combination</a> of slice! and
|
833
827
|
store. If two arguments are given it calls store. If a single argument is
|
834
828
|
give it calls slice!.
|
835
829
|
</p>
|
@@ -847,8 +841,8 @@ CREDIT: Trans
|
|
847
841
|
</p>
|
848
842
|
</div>
|
849
843
|
<div class="sourcecode">
|
850
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
851
|
-
<div id="
|
844
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000101_source')" id="l_M000101_source">+</a> ]</p>
|
845
|
+
<div id="M000101_source" class="dyn-source">
|
852
846
|
<pre>
|
853
847
|
<span class="ruby-comment cmt"># File lib/core/facets/array/splice.rb, line 17</span>
|
854
848
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">splice</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
@@ -864,7 +858,7 @@ CREDIT: Trans
|
|
864
858
|
</div>
|
865
859
|
<div class="method">
|
866
860
|
<div class="title">
|
867
|
-
<a name="
|
861
|
+
<a name="M000081"></a><b>to_b</b>()
|
868
862
|
</div>
|
869
863
|
<div class="description">
|
870
864
|
<p>
|
@@ -872,8 +866,8 @@ Boolean conversion for not empty?
|
|
872
866
|
</p>
|
873
867
|
</div>
|
874
868
|
<div class="sourcecode">
|
875
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
876
|
-
<div id="
|
869
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000081_source')" id="l_M000081_source">+</a> ]</p>
|
870
|
+
<div id="M000081_source" class="dyn-source">
|
877
871
|
<pre>
|
878
872
|
<span class="ruby-comment cmt"># File lib/core/facets/boolean.rb, line 60</span>
|
879
873
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_b</span>
|
@@ -885,51 +879,253 @@ Boolean conversion for not empty?
|
|
885
879
|
</div>
|
886
880
|
<div class="method">
|
887
881
|
<div class="title">
|
888
|
-
<a name="
|
882
|
+
<a name="M000075"></a><b>to_h</b>(mode=nil)
|
889
883
|
</div>
|
890
884
|
<div class="description">
|
891
885
|
<p>
|
892
|
-
Converts a
|
886
|
+
Converts an array into a hash. Converting an array into a hash is not a
|
887
|
+
one-to-one conversion, for this reason <a
|
888
|
+
href="Array.html#M000075">to_h</a> examines at the array being converted
|
889
|
+
and then dispatches the conversion to the most sutiable specialized
|
890
|
+
function. There are three possiblities for this.
|
891
|
+
</p>
|
892
|
+
<p>
|
893
|
+
If the array is a collection of perfect pairs, like that which Hash#to_a
|
894
|
+
generates, then conversion is handled by <a
|
895
|
+
href="Array.html#M000078">to_h_flat</a>.
|
893
896
|
</p>
|
894
897
|
<pre>
|
895
898
|
a = [ [:a,1], [:b,2] ]
|
896
899
|
a.to_h #=> { :a=>1, :b=>2 }
|
897
900
|
</pre>
|
898
901
|
<p>
|
899
|
-
If <
|
902
|
+
If the array contains <a href="Array.html#M000097">only</a> arrays, but are
|
903
|
+
not perfect pairs, then <a href="Array.html#M000080">to_h_multi</a> is
|
904
|
+
called.
|
905
|
+
</p>
|
906
|
+
<pre>
|
907
|
+
a = [ [:a,1,2], [:b,2], [:c], [:d] ]
|
908
|
+
a.to_h #=> { :a=>[1,2], :b=>[2], :c=>[], :d=>[] }
|
909
|
+
</pre>
|
910
|
+
<p>
|
911
|
+
If the array contians objects other then arrays then the <a
|
912
|
+
href="Array.html#M000077">to_h_splat</a> method is called.
|
900
913
|
</p>
|
901
914
|
<pre>
|
902
|
-
a = [ [:a,1,2],
|
903
|
-
a.to_h
|
915
|
+
a = [ [:a,1,2], 2, :b, [:c,3], 9 ]
|
916
|
+
a.to_h #=> { [:a,1,2]=>2, :b=>[:c,3], 9=>nil }
|
904
917
|
</pre>
|
905
918
|
<p>
|
906
|
-
|
907
|
-
|
919
|
+
Finally, a particular dispatch can be forced by specifying the
|
920
|
+
<tt>mode</tt> of conversion, eg. +:multi+, +:splat+, +:flat+, +:assoc+,
|
921
|
+
etc.
|
922
|
+
</p>
|
923
|
+
<p>
|
924
|
+
Setting <tt>mode</tt> to <tt>true</tt> is the same as setting it +:multi+.
|
925
|
+
This has been left in for backward compatability.
|
926
|
+
</p>
|
927
|
+
<p>
|
928
|
+
NOTE: The use of a <tt>values</tt> parameter has been deprecated because
|
929
|
+
that functionality is as simple as:
|
908
930
|
</p>
|
909
931
|
<pre>
|
910
932
|
array1.zip(array2).to_h
|
911
933
|
</pre>
|
912
934
|
<p>
|
913
|
-
CREDIT: Trans
|
935
|
+
CREDIT: Robert Klemme CREDIT: Trans
|
914
936
|
</p>
|
915
937
|
</div>
|
916
938
|
<div class="sourcecode">
|
917
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
918
|
-
<div id="
|
939
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000075_source')" id="l_M000075_source">+</a> ]</p>
|
940
|
+
<div id="M000075_source" class="dyn-source">
|
919
941
|
<pre>
|
920
|
-
<span class="ruby-comment cmt"># File lib/core/facets/to_hash.rb, line
|
921
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_h</span>(<span class="ruby-identifier">
|
922
|
-
<span class="ruby-
|
923
|
-
<span class="ruby-keyword kw">
|
924
|
-
<span class="ruby-
|
925
|
-
|
942
|
+
<span class="ruby-comment cmt"># File lib/core/facets/to_hash.rb, line 98</span>
|
943
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_h</span>(<span class="ruby-identifier">mode</span>=<span class="ruby-keyword kw">nil</span>)
|
944
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">mode</span>
|
945
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:splat</span>
|
946
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">to_h_splat</span>
|
947
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:flat</span>
|
948
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">to_h_flat</span>
|
949
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:multi</span>, <span class="ruby-keyword kw">true</span>
|
950
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">to_h_multi</span>
|
951
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:assoc</span>
|
952
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">to_h_assoc</span>
|
926
953
|
<span class="ruby-keyword kw">else</span>
|
927
|
-
<span class="ruby-
|
928
|
-
|
929
|
-
|
930
|
-
|
954
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">to_h_auto</span>
|
955
|
+
<span class="ruby-keyword kw">end</span>
|
956
|
+
<span class="ruby-keyword kw">end</span>
|
957
|
+
</pre>
|
958
|
+
</div>
|
959
|
+
</div>
|
960
|
+
</div>
|
961
|
+
<div class="method">
|
962
|
+
<div class="title">
|
963
|
+
<a name="M000079"></a><b>to_h_assoc</b>()
|
964
|
+
</div>
|
965
|
+
<div class="description">
|
966
|
+
<p>
|
967
|
+
When a mixed or multi-element accociative array is used, the result is as
|
968
|
+
follows:
|
969
|
+
</p>
|
970
|
+
<pre>
|
971
|
+
a = [ [:a,1,2], [:b,2], [:c], :d ]
|
972
|
+
a.to_h #=> { :a=>[1,2], :b=>[2], :c=>[], :d=>[] }
|
973
|
+
</pre>
|
974
|
+
<p>
|
975
|
+
If the fist entry of any subelements are the same, then the value will be
|
976
|
+
set to the last occuring value.
|
977
|
+
</p>
|
978
|
+
<pre>
|
979
|
+
a = [ :x, [:x], [:x,1,2], [:x,3], [:x,4] ]
|
980
|
+
a.to_h_assoc #=> { :x=>4 }
|
981
|
+
</pre>
|
982
|
+
</div>
|
983
|
+
<div class="sourcecode">
|
984
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000079_source')" id="l_M000079_source">+</a> ]</p>
|
985
|
+
<div id="M000079_source" class="dyn-source">
|
986
|
+
<pre>
|
987
|
+
<span class="ruby-comment cmt"># File lib/core/facets/to_hash.rb, line 202</span>
|
988
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_h_assoc</span>
|
989
|
+
<span class="ruby-identifier">h</span> = {}
|
990
|
+
<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-operator">*</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
991
|
+
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
|
992
|
+
<span class="ruby-keyword kw">end</span>
|
993
|
+
<span class="ruby-identifier">h</span>
|
994
|
+
<span class="ruby-keyword kw">end</span>
|
995
|
+
</pre>
|
996
|
+
</div>
|
997
|
+
</div>
|
998
|
+
</div>
|
999
|
+
<div class="method">
|
1000
|
+
<div class="title">
|
1001
|
+
<a name="M000076"></a><b>to_h_auto</b>()
|
1002
|
+
</div>
|
1003
|
+
<div class="description">
|
1004
|
+
<p>
|
1005
|
+
Converts an array into a hash. Converting an array into a hash is not a
|
1006
|
+
one-to-one conversion, for this reason <a
|
1007
|
+
href="Array.html#M000075">to_h</a> examines at the array being converted
|
1008
|
+
and then dispatches the conversion to the most sutiable specialized
|
1009
|
+
function. There are three possiblities for this.
|
1010
|
+
</p>
|
1011
|
+
<p>
|
1012
|
+
If the array is a collection of perfect pairs, like that which Hash#to_a
|
1013
|
+
generates, then conversion is handled by <a
|
1014
|
+
href="Array.html#M000078">to_h_flat</a>.
|
1015
|
+
</p>
|
1016
|
+
<pre>
|
1017
|
+
a = [ [:a,1], [:b,2] ]
|
1018
|
+
a.to_h #=> { :a=>1, :b=>2 }
|
1019
|
+
</pre>
|
1020
|
+
<p>
|
1021
|
+
If the array contains <a href="Array.html#M000097">only</a> arrays, but are
|
1022
|
+
not perfect pairs, then <a href="Array.html#M000080">to_h_multi</a> is
|
1023
|
+
called.
|
1024
|
+
</p>
|
1025
|
+
<pre>
|
1026
|
+
a = [ [:a,1,2], [:b,2], [:c], [:d] ]
|
1027
|
+
a.to_h #=> { :a=>[1,2], :b=>[2], :c=>[], :d=>[] }
|
1028
|
+
</pre>
|
1029
|
+
<p>
|
1030
|
+
If the array contians objects other then arrays then the <a
|
1031
|
+
href="Array.html#M000077">to_h_splat</a> method is called.
|
1032
|
+
</p>
|
1033
|
+
<pre>
|
1034
|
+
a = [ [:a,1,2], 2, :b, [:c,3], 9 ]
|
1035
|
+
a.to_h #=> { [:a,1,2]=>2, :b=>[:c,3], 9=>nil }
|
1036
|
+
</pre>
|
1037
|
+
</div>
|
1038
|
+
<div class="sourcecode">
|
1039
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000076_source')" id="l_M000076_source">+</a> ]</p>
|
1040
|
+
<div id="M000076_source" class="dyn-source">
|
1041
|
+
<pre>
|
1042
|
+
<span class="ruby-comment cmt"># File lib/core/facets/to_hash.rb, line 138</span>
|
1043
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_h_auto</span>
|
1044
|
+
<span class="ruby-identifier">pairs</span> = <span class="ruby-keyword kw">true</span>
|
1045
|
+
<span class="ruby-identifier">mixed</span> = <span class="ruby-keyword kw">false</span>
|
1046
|
+
|
1047
|
+
<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
1048
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">e</span>
|
1049
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>
|
1050
|
+
<span class="ruby-identifier">pairs</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">2</span>
|
1051
|
+
<span class="ruby-keyword kw">else</span>
|
1052
|
+
<span class="ruby-identifier">mixed</span> = <span class="ruby-keyword kw">true</span>
|
931
1053
|
<span class="ruby-keyword kw">end</span>
|
932
|
-
|
1054
|
+
<span class="ruby-keyword kw">end</span>
|
1055
|
+
|
1056
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mixed</span>
|
1057
|
+
<span class="ruby-identifier">to_h_splat</span>
|
1058
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">pairs</span>
|
1059
|
+
<span class="ruby-identifier">to_h_flat</span>
|
1060
|
+
<span class="ruby-keyword kw">else</span>
|
1061
|
+
<span class="ruby-identifier">to_h_multi</span>
|
1062
|
+
<span class="ruby-keyword kw">end</span>
|
1063
|
+
<span class="ruby-keyword kw">end</span>
|
1064
|
+
</pre>
|
1065
|
+
</div>
|
1066
|
+
</div>
|
1067
|
+
</div>
|
1068
|
+
<div class="method">
|
1069
|
+
<div class="title">
|
1070
|
+
<a name="M000078"></a><b>to_h_flat</b>()
|
1071
|
+
</div>
|
1072
|
+
<div class="description">
|
1073
|
+
<p>
|
1074
|
+
This is equivalent to <a href="http://*array.flatten">Hash</a>, but it will
|
1075
|
+
<a href="Array.html#M000102">pad</a> the array with a <tt>nil</tt> object
|
1076
|
+
if there are not an even number of elements.
|
1077
|
+
</p>
|
1078
|
+
<pre>
|
1079
|
+
a = [:a,1,[:b,2,:c]]
|
1080
|
+
a.to_h_flat #=> { :a=>1, :b=>2, :c=>nil }
|
1081
|
+
</pre>
|
1082
|
+
</div>
|
1083
|
+
<div class="sourcecode">
|
1084
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000078_source')" id="l_M000078_source">+</a> ]</p>
|
1085
|
+
<div id="M000078_source" class="dyn-source">
|
1086
|
+
<pre>
|
1087
|
+
<span class="ruby-comment cmt"># File lib/core/facets/to_hash.rb, line 180</span>
|
1088
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_h_flat</span>
|
1089
|
+
<span class="ruby-identifier">a</span> = <span class="ruby-identifier">flatten</span>
|
1090
|
+
<span class="ruby-identifier">a</span> <span class="ruby-operator"><<</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">%</span> <span class="ruby-value">2</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
1091
|
+
<span class="ruby-constant">Hash</span>[<span class="ruby-operator">*</span><span class="ruby-identifier">a</span>]
|
1092
|
+
<span class="ruby-keyword kw">end</span>
|
1093
|
+
</pre>
|
1094
|
+
</div>
|
1095
|
+
</div>
|
1096
|
+
</div>
|
1097
|
+
<div class="method">
|
1098
|
+
<div class="title">
|
1099
|
+
<a name="M000080"></a><b>to_h_multi</b>()
|
1100
|
+
</div>
|
1101
|
+
<div class="description">
|
1102
|
+
<p>
|
1103
|
+
When a mixed or multi-element accociative array is used, the result is as
|
1104
|
+
follows:
|
1105
|
+
</p>
|
1106
|
+
<pre>
|
1107
|
+
a = [ [:a,1,2], [:b,2], [:c], :d ]
|
1108
|
+
a.to_h #=> { :a=>[1,2], :b=>[2], :c=>[], :d=>[] }
|
1109
|
+
</pre>
|
1110
|
+
<p>
|
1111
|
+
If the fist entry of the subelements is the same, then the values will be
|
1112
|
+
merged using concat.
|
1113
|
+
</p>
|
1114
|
+
<pre>
|
1115
|
+
a = [ [:a,1,2], [:a,3], [:a,4], [:a], :a ]
|
1116
|
+
a.to_h_multi #=> { :a=>[1,2,3,4,nil,nil] }
|
1117
|
+
</pre>
|
1118
|
+
</div>
|
1119
|
+
<div class="sourcecode">
|
1120
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000080_source')" id="l_M000080_source">+</a> ]</p>
|
1121
|
+
<div id="M000080_source" class="dyn-source">
|
1122
|
+
<pre>
|
1123
|
+
<span class="ruby-comment cmt"># File lib/core/facets/to_hash.rb, line 222</span>
|
1124
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_h_multi</span>
|
1125
|
+
<span class="ruby-identifier">h</span> = {}
|
1126
|
+
<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-operator">*</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
1127
|
+
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">||=</span> []
|
1128
|
+
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">v</span>)
|
933
1129
|
<span class="ruby-keyword kw">end</span>
|
934
1130
|
<span class="ruby-identifier">h</span>
|
935
1131
|
<span class="ruby-keyword kw">end</span>
|
@@ -939,11 +1135,40 @@ CREDIT: Trans
|
|
939
1135
|
</div>
|
940
1136
|
<div class="method">
|
941
1137
|
<div class="title">
|
942
|
-
<a name="
|
1138
|
+
<a name="M000077"></a><b>to_h_splat</b>()
|
1139
|
+
</div>
|
1140
|
+
<div class="description">
|
1141
|
+
<p>
|
1142
|
+
This is equivalent to <a href="Hash.html">Hash</a>[*array], but it will <a
|
1143
|
+
href="Array.html#M000102">pad</a> the array with a <tt>nil</tt> object if
|
1144
|
+
there are not an even number of elements.
|
1145
|
+
</p>
|
1146
|
+
<pre>
|
1147
|
+
a = [:a,1,:b,2,:c]
|
1148
|
+
a.to_h_splat #=> { :a=>1, :b=>2, :c=>nil }
|
1149
|
+
</pre>
|
1150
|
+
</div>
|
1151
|
+
<div class="sourcecode">
|
1152
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000077_source')" id="l_M000077_source">+</a> ]</p>
|
1153
|
+
<div id="M000077_source" class="dyn-source">
|
1154
|
+
<pre>
|
1155
|
+
<span class="ruby-comment cmt"># File lib/core/facets/to_hash.rb, line 167</span>
|
1156
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_h_splat</span>
|
1157
|
+
<span class="ruby-identifier">a</span> = <span class="ruby-identifier">dup</span>
|
1158
|
+
<span class="ruby-identifier">a</span> <span class="ruby-operator"><<</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">%</span> <span class="ruby-value">2</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
1159
|
+
<span class="ruby-constant">Hash</span>[<span class="ruby-operator">*</span><span class="ruby-identifier">a</span>]
|
1160
|
+
<span class="ruby-keyword kw">end</span>
|
1161
|
+
</pre>
|
1162
|
+
</div>
|
1163
|
+
</div>
|
1164
|
+
</div>
|
1165
|
+
<div class="method">
|
1166
|
+
<div class="title">
|
1167
|
+
<a name="M000092"></a><b>traverse</b>() {|item| ...}
|
943
1168
|
</div>
|
944
1169
|
<div class="sourcecode">
|
945
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
946
|
-
<div id="
|
1170
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000092_source')" id="l_M000092_source">+</a> ]</p>
|
1171
|
+
<div id="M000092_source" class="dyn-source">
|
947
1172
|
<pre>
|
948
1173
|
<span class="ruby-comment cmt"># File lib/core/facets/array/traverse.rb, line 5</span>
|
949
1174
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">traverse</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
@@ -961,11 +1186,11 @@ CREDIT: Trans
|
|
961
1186
|
</div>
|
962
1187
|
<div class="method">
|
963
1188
|
<div class="title">
|
964
|
-
<a name="
|
1189
|
+
<a name="M000093"></a><b>traverse!</b>(&block)
|
965
1190
|
</div>
|
966
1191
|
<div class="sourcecode">
|
967
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
968
|
-
<div id="
|
1192
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000093_source')" id="l_M000093_source">+</a> ]</p>
|
1193
|
+
<div id="M000093_source" class="dyn-source">
|
969
1194
|
<pre>
|
970
1195
|
<span class="ruby-comment cmt"># File lib/core/facets/array/traverse.rb, line 17</span>
|
971
1196
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">traverse!</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|