shenanigans 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -3
  3. data/README.rdoc +1 -1
  4. data/doc/Array.html +423 -202
  5. data/doc/Fixnum.html +155 -140
  6. data/doc/Hash.html +305 -206
  7. data/doc/Kernel.html +360 -249
  8. data/doc/Module.html +181 -153
  9. data/doc/Object.html +210 -201
  10. data/doc/String.html +166 -139
  11. data/doc/_index.html +188 -0
  12. data/doc/class_list.html +54 -0
  13. data/doc/css/common.css +1 -0
  14. data/doc/css/full_list.css +57 -0
  15. data/doc/css/style.css +338 -0
  16. data/doc/file.README.html +162 -0
  17. data/doc/file_list.html +56 -0
  18. data/doc/frames.html +26 -0
  19. data/doc/index.html +62 -80
  20. data/doc/js/app.js +219 -0
  21. data/doc/js/full_list.js +178 -0
  22. data/doc/js/jquery.js +4 -18
  23. data/doc/method_list.html +149 -0
  24. data/doc/top-level-namespace.html +114 -0
  25. data/lib/shenanigans.rb +3 -1
  26. data/lib/shenanigans/array.rb +3 -3
  27. data/lib/shenanigans/array/reductions.rb +29 -0
  28. data/lib/shenanigans/kernel.rb +4 -4
  29. data/lib/shenanigans/module.rb +1 -1
  30. data/lib/shenanigans/object.rb +2 -2
  31. data/lib/shenanigans/string.rb +1 -1
  32. data/test/array/test_reductions.rb +27 -0
  33. metadata +16 -36
  34. data/doc/README_rdoc.html +0 -199
  35. data/doc/created.rid +0 -25
  36. data/doc/images/add.png +0 -0
  37. data/doc/images/arrow_up.png +0 -0
  38. data/doc/images/brick.png +0 -0
  39. data/doc/images/brick_link.png +0 -0
  40. data/doc/images/bug.png +0 -0
  41. data/doc/images/bullet_black.png +0 -0
  42. data/doc/images/bullet_toggle_minus.png +0 -0
  43. data/doc/images/bullet_toggle_plus.png +0 -0
  44. data/doc/images/date.png +0 -0
  45. data/doc/images/delete.png +0 -0
  46. data/doc/images/find.png +0 -0
  47. data/doc/images/loadingAnimation.gif +0 -0
  48. data/doc/images/macFFBgHack.png +0 -0
  49. data/doc/images/package.png +0 -0
  50. data/doc/images/page_green.png +0 -0
  51. data/doc/images/page_white_text.png +0 -0
  52. data/doc/images/page_white_width.png +0 -0
  53. data/doc/images/plugin.png +0 -0
  54. data/doc/images/ruby.png +0 -0
  55. data/doc/images/tag_blue.png +0 -0
  56. data/doc/images/tag_green.png +0 -0
  57. data/doc/images/transparent.png +0 -0
  58. data/doc/images/wrench.png +0 -0
  59. data/doc/images/wrench_orange.png +0 -0
  60. data/doc/images/zoom.png +0 -0
  61. data/doc/js/darkfish.js +0 -155
  62. data/doc/js/navigation.js +0 -142
  63. data/doc/js/search.js +0 -94
  64. data/doc/js/search_index.js +0 -1
  65. data/doc/js/searcher.js +0 -228
  66. data/doc/rdoc.css +0 -595
  67. data/doc/table_of_contents.html +0 -114
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c51ac956ec8c326d6f7bbb962d1c226df339a93
4
- data.tar.gz: d1300bab95b3c6f7d103f384968459cbd8675aa9
3
+ metadata.gz: 2e044d2e0504fe9effa8d5ab1ded585d95a0d0c1
4
+ data.tar.gz: a249b7f56f152919252ad63491f26d77ed00868e
5
5
  SHA512:
6
- metadata.gz: 1662c5ccfbe51264f092d8aa104ff1db3a2085ab7724d750cc92a3e42c39d404c95d344f064f80afc7c1daba80d4ba81d6d582d6b654ae0fa5f1ffbea9c0a9df
7
- data.tar.gz: 3ddb1d799672c6a8e08b70a2cbbc2bc612969dc5f954fd6686986e75e5cc2bcaa8ba330489f168e09ceb453bb24268d592f5d0b28480c5c92e9a97e18e2e8099
6
+ metadata.gz: 970384c5685779c928b2cf4347d4722148999ab9962bf0c9b9bafe7b64d5bbd437e0a8e2359b4387b2857571f8007fdbe5c964aa2c994111f5424f67bb535000
7
+ data.tar.gz: 4700cacb85b89461dc89ad01f954a8b2b5d0a632307c8c36713f3125b588fc91007b1d8a6450a1916a2aa88498b6cd06e577c0e4b616eab13427f9f086edb58b
data/Gemfile CHANGED
@@ -1,5 +1,8 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem "rake"
4
- gem "minitest", ">= 2.6.0", :group => :development
5
- gem "rdoc", :group => :development
4
+
5
+ group :developement do
6
+ gem "minitest", ">= 2.6.0"
7
+ gem "yard"
8
+ end
data/README.rdoc CHANGED
@@ -48,7 +48,7 @@ This project was created by Michael Kohl. He can be reached via email at citizen
48
48
 
49
49
  == License
50
50
 
51
- Copyright (c) 2012 Michael Kohl
51
+ Copyright (c) 2012-2014 Michael Kohl
52
52
 
53
53
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
54
54
 
data/doc/Array.html CHANGED
@@ -1,246 +1,451 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: Array
8
+
9
+ &mdash; Documentation by YARD 0.8.7.3
10
+
11
+ </title>
6
12
 
7
- <title>class Array - Shenanigans</title>
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
8
14
 
9
- <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
10
16
 
11
- <script type="text/javascript">
12
- var rdoc_rel_prefix = "./";
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!" + escape(window.location.href);
13
21
  </script>
14
22
 
15
- <script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
16
- <script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
17
- <script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
18
- <script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
19
- <script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
20
- <script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
21
23
 
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
22
25
 
23
- <body id="top" class="class">
24
- <nav id="metadata">
25
- <nav id="home-section" class="section">
26
- <h3 class="section-header">
27
- <a href="./index.html">Home</a>
28
- <a href="./table_of_contents.html#classes">Classes</a>
29
- <a href="./table_of_contents.html#methods">Methods</a>
30
- </h3>
31
- </nav>
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
32
27
 
33
28
 
34
- <nav id="search-section" class="section project-section" class="initially-hidden">
35
- <form action="#" method="get" accept-charset="utf-8">
36
- <h3 class="section-header">
37
- <input type="text" name="search" placeholder="Search" id="search-field"
38
- title="Type to search, Up and Down to navigate, Enter to load">
39
- </h3>
40
- </form>
41
-
42
- <ul id="search-results" class="initially-hidden"></ul>
43
- </nav>
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index (A)</a> &raquo;
35
+
36
+
37
+ <span class="title">Array</span>
38
+
44
39
 
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
45
42
 
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
46
49
 
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
47
63
 
48
- <div id="file-metadata">
49
- <nav id="file-list-section" class="section">
50
- <h3 class="section-header">Defined In</h3>
51
- <ul>
52
- <li>lib/shenanigans/array/caret.rb
53
- <li>lib/shenanigans/array/random_subarray.rb
54
- <li>lib/shenanigans/array/zip_with.rb
55
- </ul>
56
- </nav>
64
+ <iframe id="search_frame"></iframe>
57
65
 
58
-
59
- </div>
66
+ <div id="content"><h1>Class: Array
67
+
68
+
69
+
70
+ </h1>
60
71
 
61
- <div id="class-metadata">
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName"><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></span>
77
+
78
+ <ul class="fullTree">
79
+ <li><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></li>
80
+
81
+ <li class="next">Array</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
62
87
 
63
- <nav id="parent-class-section" class="section">
64
- <h3 class="section-header">Parent</h3>
65
88
 
66
- <p class="link"><a href="Object.html">Object</a>
67
89
 
68
- </nav>
69
-
70
90
 
91
+
71
92
 
72
- <!-- Method Quickref -->
73
- <nav id="method-list-section" class="section">
74
- <h3 class="section-header">Methods</h3>
93
+
94
+
95
+
96
+ <dt class="r2 last">Defined in:</dt>
97
+ <dd class="r2 last">lib/shenanigans/array/caret.rb<span class="defines">,<br />
98
+ lib/shenanigans/array/zip_with.rb,<br /> lib/shenanigans/array/reductions.rb,<br /> lib/shenanigans/array/random_subarray.rb</span>
99
+ </dd>
100
+
101
+ </dl>
102
+ <div class="clear"></div>
75
103
 
76
- <ul class="link-list">
77
-
78
- <li ><a href="#method-i-5E">#^</a>
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+ <h2>
113
+ Instance Method Summary
114
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
115
+ </h2>
116
+
117
+ <ul class="summary">
118
+
119
+ <li class="public ">
120
+ <span class="summary_signature">
79
121
 
80
- <li ><a href="#method-i-random_subarray">#random_subarray</a>
122
+ <a href="#%5E-instance_method" title="#^ (instance method)">- (Object) <strong>^</strong>(other) </a>
81
123
 
82
- <li ><a href="#method-i-zip_with">#zip_with</a>
124
+
83
125
 
84
- </ul>
85
- </nav>
126
+ </span>
127
+
128
+
129
+
130
+
131
+
132
+
133
+
86
134
 
87
- </div>
135
+
136
+ <span class="summary_desc"><div class='inline'>
137
+ <p>Returns an array containing elements exclusive between two arrays.</p>
138
+ </div></span>
139
+
140
+ </li>
88
141
 
89
- <div id="project-metadata">
90
- <nav id="fileindex-section" class="section project-section">
91
- <h3 class="section-header">Pages</h3>
142
+
143
+ <li class="public ">
144
+ <span class="summary_signature">
145
+
146
+ <a href="#random_subarray-instance_method" title="#random_subarray (instance method)">- (Object) <strong>random_subarray</strong>(n = 1) </a>
147
+
92
148
 
93
- <ul>
149
+
150
+ </span>
151
+
152
+
153
+
154
+
155
+
94
156
 
95
- <li class="file"><a href="./README_rdoc.html">README</a>
96
157
 
97
- </ul>
98
- </nav>
99
-
100
- <nav id="classindex-section" class="section project-section">
101
- <h3 class="section-header">Class and Module Index</h3>
102
158
 
103
- <ul class="link-list">
104
159
 
105
- <li><a href="./Array.html">Array</a>
160
+ <span class="summary_desc"><div class='inline'>
161
+ <p>Generates random subarrays.</p>
162
+ </div></span>
163
+
164
+ </li>
165
+
166
+
167
+ <li class="public ">
168
+ <span class="summary_signature">
169
+
170
+ <a href="#reductions-instance_method" title="#reductions (instance method)">- (Object) <strong>reductions</strong>(*args, &amp;block) </a>
171
+
172
+
173
+
174
+ </span>
106
175
 
107
- <li><a href="./Fixnum.html">Fixnum</a>
108
176
 
109
- <li><a href="./Hash.html">Hash</a>
110
177
 
111
- <li><a href="./Kernel.html">Kernel</a>
112
178
 
113
- <li><a href="./Module.html">Module</a>
114
179
 
115
- <li><a href="./Object.html">Object</a>
116
180
 
117
- <li><a href="./String.html">String</a>
118
181
 
119
- </ul>
120
- </nav>
121
182
 
122
- </div>
123
- </nav>
183
+
184
+ <span class="summary_desc"><div class='inline'>
185
+ <p>Similar to <code>reduce</code>/<code>inject</code>, but also returns
186
+ intermediate values.</p>
187
+ </div></span>
188
+
189
+ </li>
124
190
 
125
- <div id="documentation">
126
- <h1 class="class">class Array</h1>
191
+
192
+ <li class="public ">
193
+ <span class="summary_signature">
194
+
195
+ <a href="#zip_with-instance_method" title="#zip_with (instance method)">- (Object) <strong>zip_with</strong>(other, op = nil) </a>
196
+
127
197
 
128
- <div id="description" class="description">
129
198
 
130
- </div><!-- description -->
199
+ </span>
200
+
201
+
202
+
203
+
204
+
205
+
206
+
131
207
 
132
208
 
209
+ <span class="summary_desc"><div class='inline'>
210
+ <p>Zip self with other, combining the elements with the provided block or
211
+ symbol.</p>
212
+ </div></span>
133
213
 
214
+ </li>
215
+
216
+
217
+ </ul>
134
218
 
135
- <section id="5Buntitled-5D" class="documentation-section">
136
-
137
219
 
138
-
139
220
 
140
-
141
221
 
142
-
222
+ <div id="instance_method_details" class="method_details_list">
223
+ <h2>Instance Method Details</h2>
143
224
 
144
- <!-- Methods -->
145
225
 
146
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
147
- <h3 class="section-header">Public Instance Methods</h3>
226
+ <div class="method_details first">
227
+ <h3 class="signature first" id="^-instance_method">
228
+
229
+ - (<tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>) <strong>^</strong>(other)
230
+
148
231
 
149
-
150
- <div id="method-i-5E" class="method-detail ">
151
-
152
- <div class="method-heading">
153
- <span class="method-name">^</span><span
154
- class="method-args">(other)</span>
155
-
156
- <span class="method-click-advice">click to toggle source</span>
157
-
158
- </div>
159
-
232
+
160
233
 
161
- <div class="method-description">
162
-
163
- <p>Returns an array containing elements exclusive between two arrays.</p>
234
+
235
+ </h3><div class="docstring">
236
+ <div class="discussion">
237
+
238
+ <p>Returns an array containing elements exclusive between two arrays.</p>
164
239
 
165
240
  <pre class="ruby">[<span class="ruby-value">1</span>, <span class="ruby-value">2</span>, <span class="ruby-value">3</span>] <span class="ruby-operator">^</span> [<span class="ruby-value">1</span>, <span class="ruby-value">2</span>, <span class="ruby-value">4</span>]
166
241
  <span class="ruby-comment">#=&gt; [3, 4]</span>
167
242
  </pre>
168
-
169
-
170
-
171
-
172
- <div class="method-source-code" id="5E-source">
173
- <pre><span class="ruby-comment"># File lib/shenanigans/array/caret.rb, line 5</span>
174
- <span class="ruby-keyword">def</span> <span class="ruby-operator">^</span>(<span class="ruby-identifier">other</span>)
175
- (<span class="ruby-keyword">self</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">other</span>) <span class="ruby-operator">|</span> (<span class="ruby-identifier">other</span> <span class="ruby-operator">-</span> <span class="ruby-keyword">self</span>)
176
- <span class="ruby-keyword">end</span></pre>
177
- </div><!-- 5E-source -->
178
-
179
- </div>
180
243
 
181
-
182
244
 
183
-
184
- </div><!-- 5E-method -->
245
+ </div>
246
+ </div>
247
+ <div class="tags">
248
+
185
249
 
250
+ </div><table class="source_code">
251
+ <tr>
252
+ <td>
253
+ <pre class="lines">
254
+
255
+
256
+ 5
257
+ 6
258
+ 7</pre>
259
+ </td>
260
+ <td>
261
+ <pre class="code"><span class="info file"># File 'lib/shenanigans/array/caret.rb', line 5</span>
262
+
263
+ <span class='kw'>def</span> <span class='op'>^</span><span class='lparen'>(</span><span class='id identifier rubyid_other'>other</span><span class='rparen'>)</span>
264
+ <span class='lparen'>(</span><span class='kw'>self</span> <span class='op'>-</span> <span class='id identifier rubyid_other'>other</span><span class='rparen'>)</span> <span class='op'>|</span> <span class='lparen'>(</span><span class='id identifier rubyid_other'>other</span> <span class='op'>-</span> <span class='kw'>self</span><span class='rparen'>)</span>
265
+ <span class='kw'>end</span></pre>
266
+ </td>
267
+ </tr>
268
+ </table>
269
+ </div>
186
270
 
187
- <div id="method-i-random_subarray" class="method-detail ">
188
-
189
- <div class="method-heading">
190
- <span class="method-name">random_subarray</span><span
191
- class="method-args">(n=1)</span>
192
-
193
- <span class="method-click-advice">click to toggle source</span>
194
-
195
- </div>
196
-
271
+ <div class="method_details ">
272
+ <h3 class="signature " id="random_subarray-instance_method">
273
+
274
+ - (<tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>) <strong>random_subarray</strong>(n = 1)
275
+
197
276
 
198
- <div class="method-description">
199
-
200
- <p>Generates random subarrays. Uses random numbers and bit-fiddling to assure
277
+
278
+
279
+
280
+ </h3><div class="docstring">
281
+ <div class="discussion">
282
+
283
+ <p>Generates random subarrays. Uses random numbers and bit-fiddling to assure
201
284
  performant uniform distributions even for large arrays.</p>
202
285
 
203
286
  <pre class="ruby"><span class="ruby-identifier">a</span> = <span class="ruby-operator">*</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">5</span>
204
287
  <span class="ruby-identifier">a</span>.<span class="ruby-identifier">random_subarray</span>(<span class="ruby-value">3</span>)
205
288
  <span class="ruby-comment">#=&gt; [[1, 3, 5], [2, 4], [1, 3, 4, 5]]</span>
206
289
  </pre>
207
-
208
-
209
290
 
210
-
211
- <div class="method-source-code" id="random_subarray-source">
212
- <pre><span class="ruby-comment"># File lib/shenanigans/array/random_subarray.rb, line 9</span>
213
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">random_subarray</span>(<span class="ruby-identifier">n</span>=<span class="ruby-value">1</span>)
214
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;negative argument&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">n</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span>
215
- (<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">n</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span>
216
- <span class="ruby-identifier">r</span> = <span class="ruby-identifier">rand</span>(<span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-keyword">self</span>.<span class="ruby-identifier">size</span>)
217
- <span class="ruby-keyword">self</span>.<span class="ruby-identifier">select</span>.<span class="ruby-identifier">with_index</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">_</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">r</span>[<span class="ruby-identifier">i</span>] <span class="ruby-operator">==</span> <span class="ruby-value">1</span> }
218
- <span class="ruby-keyword">end</span>
219
- <span class="ruby-keyword">end</span></pre>
220
- </div><!-- random_subarray-source -->
221
-
222
- </div>
223
291
 
224
-
292
+ </div>
293
+ </div>
294
+ <div class="tags">
295
+
296
+ <p class="tag_title">Raises:</p>
297
+ <ul class="raise">
298
+
299
+ <li>
300
+
301
+
302
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
303
+
304
+
305
+
306
+ </li>
307
+
308
+ </ul>
309
+
310
+ </div><table class="source_code">
311
+ <tr>
312
+ <td>
313
+ <pre class="lines">
314
+
315
+
316
+ 9
317
+ 10
318
+ 11
319
+ 12
320
+ 13
321
+ 14
322
+ 15</pre>
323
+ </td>
324
+ <td>
325
+ <pre class="code"><span class="info file"># File 'lib/shenanigans/array/random_subarray.rb', line 9</span>
326
+
327
+ <span class='kw'>def</span> <span class='id identifier rubyid_random_subarray'>random_subarray</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='op'>=</span><span class='int'>1</span><span class='rparen'>)</span>
328
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>negative argument</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_n'>n</span> <span class='op'>&lt;</span> <span class='int'>0</span>
329
+ <span class='lparen'>(</span><span class='int'>1</span><span class='op'>..</span><span class='id identifier rubyid_n'>n</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span>
330
+ <span class='id identifier rubyid_r'>r</span> <span class='op'>=</span> <span class='id identifier rubyid_rand'>rand</span><span class='lparen'>(</span><span class='int'>2</span><span class='op'>**</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='rparen'>)</span>
331
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='period'>.</span><span class='id identifier rubyid_with_index'>with_index</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_i'>i</span><span class='op'>|</span> <span class='id identifier rubyid_r'>r</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='int'>1</span> <span class='rbrace'>}</span>
332
+ <span class='kw'>end</span>
333
+ <span class='kw'>end</span></pre>
334
+ </td>
335
+ </tr>
336
+ </table>
337
+ </div>
338
+
339
+ <div class="method_details ">
340
+ <h3 class="signature " id="reductions-instance_method">
341
+
342
+ - (<tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>) <strong>reductions</strong>(*args, &amp;block)
343
+
225
344
 
226
-
227
- </div><!-- random_subarray-method -->
345
+
228
346
 
347
+
348
+ </h3><div class="docstring">
349
+ <div class="discussion">
229
350
 
230
- <div id="method-i-zip_with" class="method-detail ">
231
-
232
- <div class="method-heading">
233
- <span class="method-name">zip_with</span><span
234
- class="method-args">(other, op=nil) { |a, b| ... }</span>
235
-
236
- <span class="method-click-advice">click to toggle source</span>
237
-
238
- </div>
239
-
351
+ <p>Similar to <code>reduce</code>/<code>inject</code>, but also returns
352
+ intermediate values. Has the same interface as
353
+ <code>reduce</code>/<code>inject</code>, so an initial value, an oprator or
354
+ both can be supplied. This method may eventually be moved to the
355
+ <code>Enumerable</code> module.</p>
356
+
357
+ <pre class="ruby"><span class="ruby-identifier">a</span> = [<span class="ruby-operator">*</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">4</span>]
358
+ <span class="ruby-identifier">a</span>.<span class="ruby-identifier">reductions</span>(:<span class="ruby-operator">+</span>)
359
+ <span class="ruby-comment">#=&gt; 10</span>
360
+ <span class="ruby-identifier">a</span>.<span class="ruby-identifier">reductions</span>(<span class="ruby-value">50</span>, :<span class="ruby-operator">+</span>)
361
+ <span class="ruby-comment">#=&gt; 60</span>
362
+ <span class="ruby-node">%w(a b c)</span>.<span class="ruby-identifier">reductions</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">s1</span>, <span class="ruby-identifier">s2</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s1</span><span class="ruby-operator">+</span><span class="ruby-identifier">s2</span> }
363
+ <span class="ruby-comment">#=&gt; [&quot;a&quot;, &quot;ab&quot;, &quot;abc&quot;]</span>
364
+ </pre>
240
365
 
241
- <div class="method-description">
242
-
243
- <p>Zip <code>self</code> with <code>other</code>, combining the elements with
366
+
367
+ </div>
368
+ </div>
369
+ <div class="tags">
370
+
371
+ <p class="tag_title">Raises:</p>
372
+ <ul class="raise">
373
+
374
+ <li>
375
+
376
+
377
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
378
+
379
+
380
+
381
+ </li>
382
+
383
+ </ul>
384
+
385
+ </div><table class="source_code">
386
+ <tr>
387
+ <td>
388
+ <pre class="lines">
389
+
390
+
391
+ 11
392
+ 12
393
+ 13
394
+ 14
395
+ 15
396
+ 16
397
+ 17
398
+ 18
399
+ 19
400
+ 20
401
+ 21
402
+ 22
403
+ 23
404
+ 24
405
+ 25
406
+ 26
407
+ 27
408
+ 28</pre>
409
+ </td>
410
+ <td>
411
+ <pre class="code"><span class="info file"># File 'lib/shenanigans/array/reductions.rb', line 11</span>
412
+
413
+ <span class='kw'>def</span> <span class='id identifier rubyid_reductions'>reductions</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
414
+ <span class='id identifier rubyid_arr'>arr</span> <span class='op'>=</span> <span class='id identifier rubyid_dup'>dup</span>
415
+
416
+ <span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>1</span>
417
+ <span class='const'>Symbol</span> <span class='op'>===</span> <span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span> <span class='op'>=</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_op'>op</span> <span class='op'>=</span> <span class='id identifier rubyid_arg'>arg</span> <span class='op'>:</span> <span class='id identifier rubyid_initial'>initial</span> <span class='op'>=</span> <span class='id identifier rubyid_arg'>arg</span>
418
+ <span class='kw'>else</span>
419
+ <span class='id identifier rubyid_initial'>initial</span><span class='comma'>,</span> <span class='id identifier rubyid_op'>op</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span> <span class='op'>=</span> <span class='id identifier rubyid_args'>args</span>
420
+ <span class='kw'>end</span>
421
+
422
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Need an operator or block</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_op'>op</span> <span class='op'>||</span> <span class='id identifier rubyid_block'>block</span>
423
+
424
+ <span class='id identifier rubyid_initial'>initial</span> <span class='op'>||=</span> <span class='id identifier rubyid_arr'>arr</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
425
+
426
+ <span class='id identifier rubyid_arr'>arr</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='id identifier rubyid_initial'>initial</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='id identifier rubyid_initial'>initial</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='lparen'>(</span><span class='id identifier rubyid_acc'>acc</span><span class='comma'>,</span> <span class='id identifier rubyid_result'>result</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_el'>el</span><span class='op'>|</span>
427
+ <span class='id identifier rubyid_val'>val</span> <span class='op'>=</span> <span class='id identifier rubyid_op'>op</span> <span class='op'>?</span> <span class='id identifier rubyid_acc'>acc</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_op'>op</span><span class='comma'>,</span> <span class='id identifier rubyid_el'>el</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>yield</span><span class='lparen'>(</span><span class='id identifier rubyid_acc'>acc</span><span class='comma'>,</span> <span class='id identifier rubyid_el'>el</span><span class='rparen'>)</span>
428
+ <span class='lbracket'>[</span><span class='id identifier rubyid_val'>val</span><span class='comma'>,</span> <span class='id identifier rubyid_result'>result</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_val'>val</span><span class='rbracket'>]</span>
429
+ <span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span>
430
+ <span class='kw'>end</span></pre>
431
+ </td>
432
+ </tr>
433
+ </table>
434
+ </div>
435
+
436
+ <div class="method_details ">
437
+ <h3 class="signature " id="zip_with-instance_method">
438
+
439
+ - (<tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>) <strong>zip_with</strong>(other, op = nil)
440
+
441
+
442
+
443
+
444
+
445
+ </h3><div class="docstring">
446
+ <div class="discussion">
447
+
448
+ <p>Zip <code>self</code> with <code>other</code>, combining the elements with
244
449
  the provided block or symbol. The resulting array will be as long as the
245
450
  shorter of the two arrays.</p>
246
451
 
@@ -255,43 +460,59 @@ shorter of the two arrays.</p>
255
460
  <pre class="ruby">[<span class="ruby-value">1</span>,<span class="ruby-value">2</span>,<span class="ruby-value">3</span>].<span class="ruby-identifier">zip_with</span>([<span class="ruby-value">6</span>,<span class="ruby-value">5</span>,<span class="ruby-value">4</span>]) { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-value">3</span><span class="ruby-operator">*</span><span class="ruby-identifier">a</span><span class="ruby-operator">+</span><span class="ruby-value">2</span><span class="ruby-operator">*</span><span class="ruby-identifier">b</span> }
256
461
  <span class="ruby-comment">#=&gt; [15, 16, 17]</span>
257
462
  </pre>
258
-
259
-
260
463
 
261
-
262
- <div class="method-source-code" id="zip_with-source">
263
- <pre><span class="ruby-comment"># File lib/shenanigans/array/zip_with.rb, line 16</span>
264
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">zip_with</span>(<span class="ruby-identifier">other</span>, <span class="ruby-identifier">op</span>=<span class="ruby-keyword">nil</span>)
265
- <span class="ruby-keyword">return</span> [] <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">empty?</span>
266
- <span class="ruby-identifier">clipped</span> = <span class="ruby-keyword">self</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">other</span>.<span class="ruby-identifier">length</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>]
267
- <span class="ruby-identifier">zipped</span> = <span class="ruby-identifier">clipped</span>.<span class="ruby-identifier">zip</span>(<span class="ruby-identifier">other</span>)
268
-
269
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">op</span>
270
- <span class="ruby-identifier">zipped</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">op</span>, <span class="ruby-identifier">b</span>) }
271
- <span class="ruby-keyword">else</span>
272
- <span class="ruby-identifier">zipped</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>) }
273
- <span class="ruby-keyword">end</span>
274
- <span class="ruby-keyword">end</span></pre>
275
- </div><!-- zip_with-source -->
276
-
277
- </div>
278
-
279
-
280
-
281
-
282
- </div><!-- zip_with-method -->
283
464
 
284
-
285
- </section><!-- public-instance-method-details -->
465
+ </div>
466
+ </div>
467
+ <div class="tags">
286
468
 
287
- </section><!-- 5Buntitled-5D -->
288
469
 
289
- </div><!-- documentation -->
470
+ </div><table class="source_code">
471
+ <tr>
472
+ <td>
473
+ <pre class="lines">
474
+
475
+
476
+ 16
477
+ 17
478
+ 18
479
+ 19
480
+ 20
481
+ 21
482
+ 22
483
+ 23
484
+ 24
485
+ 25
486
+ 26</pre>
487
+ </td>
488
+ <td>
489
+ <pre class="code"><span class="info file"># File 'lib/shenanigans/array/zip_with.rb', line 16</span>
490
+
491
+ <span class='kw'>def</span> <span class='id identifier rubyid_zip_with'>zip_with</span><span class='lparen'>(</span><span class='id identifier rubyid_other'>other</span><span class='comma'>,</span> <span class='id identifier rubyid_op'>op</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
492
+ <span class='kw'>return</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>||</span> <span class='id identifier rubyid_other'>other</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
493
+ <span class='id identifier rubyid_clipped'>clipped</span> <span class='op'>=</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>..</span><span class='id identifier rubyid_other'>other</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span>
494
+ <span class='id identifier rubyid_zipped'>zipped</span> <span class='op'>=</span> <span class='id identifier rubyid_clipped'>clipped</span><span class='period'>.</span><span class='id identifier rubyid_zip'>zip</span><span class='lparen'>(</span><span class='id identifier rubyid_other'>other</span><span class='rparen'>)</span>
495
+
496
+ <span class='kw'>if</span> <span class='id identifier rubyid_op'>op</span>
497
+ <span class='id identifier rubyid_zipped'>zipped</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='op'>|</span> <span class='id identifier rubyid_a'>a</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_op'>op</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
498
+ <span class='kw'>else</span>
499
+ <span class='id identifier rubyid_zipped'>zipped</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='op'>|</span> <span class='kw'>yield</span><span class='lparen'>(</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
500
+ <span class='kw'>end</span>
501
+ <span class='kw'>end</span></pre>
502
+ </td>
503
+ </tr>
504
+ </table>
505
+ </div>
506
+
507
+ </div>
290
508
 
509
+ </div>
291
510
 
292
- <footer id="validator-badges">
293
- <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
294
- <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
295
- <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
296
- </footer>
511
+ <div id="footer">
512
+ Generated on Tue Dec 31 15:41:29 2013 by
513
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
514
+ 0.8.7.3 (ruby-2.0.0).
515
+ </div>
297
516
 
517
+ </body>
518
+ </html>