shenanigans 1.0.10 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Gemfile +2 -1
- data/lib/shenanigans/array/caret.rb +3 -2
- data/lib/shenanigans/array/random_subarray.rb +7 -5
- data/lib/shenanigans/array/reductions.rb +13 -10
- data/lib/shenanigans/array/zip_with.rb +9 -12
- data/lib/shenanigans/array.rb +3 -3
- data/lib/shenanigans/hash/extract.rb +5 -4
- data/lib/shenanigans/hash/has_shape_pred.rb +6 -7
- data/lib/shenanigans/hash/to_ostruct.rb +8 -9
- data/lib/shenanigans/hash.rb +3 -3
- data/lib/shenanigans/integer/divisible_by.rb +13 -0
- data/lib/shenanigans/integer/string_length.rb +13 -0
- data/lib/shenanigans/integer.rb +2 -0
- data/lib/shenanigans/kernel/fn.rb +6 -5
- data/lib/shenanigans/kernel/prompt.rb +6 -7
- data/lib/shenanigans/kernel/require_optional.rb +7 -7
- data/lib/shenanigans/kernel/with.rb +3 -2
- data/lib/shenanigans/kernel.rb +4 -4
- data/lib/shenanigans/module/private_accessor.rb +5 -5
- data/lib/shenanigans/module.rb +1 -1
- data/lib/shenanigans/object/display.rb +5 -4
- data/lib/shenanigans/object.rb +1 -2
- data/lib/shenanigans/string/cmpi.rb +9 -0
- data/lib/shenanigans/string/in_groups_of.rb +4 -6
- data/lib/shenanigans/string.rb +2 -1
- data/lib/shenanigans.rb +7 -7
- data/test/array/caret_test.rb +9 -0
- data/test/array/{test_random_subarray.rb → random_subarray_test.rb} +3 -3
- data/test/array/reductions_test.rb +27 -0
- data/test/array/zip_with_test.rb +14 -0
- data/test/hash/extract_test.rb +11 -0
- data/test/hash/{test_has_shape_pred.rb → has_shape_pred_test.rb} +3 -3
- data/test/hash/{test_to_ostruct.rb → to_ostruct_test.rb} +3 -3
- data/test/integer/divisible_by_test.rb +16 -0
- data/test/integer/string_length_test.rb +16 -0
- data/test/kernel/fn_test.rb +14 -0
- data/test/kernel/{test_prompt.rb → prompt_test.rb} +4 -4
- data/test/kernel/require_optional_test.rb +15 -0
- data/test/kernel/with_test.rb +12 -0
- data/test/module/{test_private_accessor.rb → private_accessor_test.rb} +3 -3
- data/test/object/{test_display.rb → display_test.rb} +4 -5
- data/test/string/cmpi_test.rb +10 -0
- data/test/string/in_groups_of_test.rb +11 -0
- metadata +40 -62
- data/doc/Array.html +0 -518
- data/doc/Fixnum.html +0 -214
- data/doc/Hash.html +0 -415
- data/doc/Kernel.html +0 -462
- data/doc/Module.html +0 -236
- data/doc/Object.html +0 -284
- data/doc/String.html +0 -226
- data/doc/_index.html +0 -188
- data/doc/class_list.html +0 -54
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -57
- data/doc/css/style.css +0 -338
- data/doc/file.README.html +0 -162
- data/doc/file_list.html +0 -56
- data/doc/frames.html +0 -26
- data/doc/index.html +0 -162
- data/doc/js/app.js +0 -219
- data/doc/js/full_list.js +0 -178
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -149
- data/doc/top-level-namespace.html +0 -114
- data/lib/shenanigans/fixnum/string_length.rb +0 -14
- data/lib/shenanigans/fixnum.rb +0 -1
- data/lib/shenanigans/object/it.rb +0 -9
- data/test/array/test_caret.rb +0 -9
- data/test/array/test_reductions.rb +0 -27
- data/test/array/test_zip_with.rb +0 -14
- data/test/fixnum/test_string_length.rb +0 -16
- data/test/hash/test_extract.rb +0 -11
- data/test/kernel/test_fn.rb +0 -14
- data/test/kernel/test_require_optional.rb +0 -17
- data/test/kernel/test_with.rb +0 -12
- data/test/object/test_it.rb +0 -10
- data/test/string/test_display.rb +0 -36
- data/test/string/test_in_groups_of.rb +0 -11
data/doc/Kernel.html
DELETED
@@ -1,462 +0,0 @@
|
|
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
|
-
Module: Kernel
|
8
|
-
|
9
|
-
— Documentation by YARD 0.8.7.3
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
-
|
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);
|
21
|
-
</script>
|
22
|
-
|
23
|
-
|
24
|
-
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
25
|
-
|
26
|
-
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
27
|
-
|
28
|
-
|
29
|
-
</head>
|
30
|
-
<body>
|
31
|
-
<div id="header">
|
32
|
-
<div id="menu">
|
33
|
-
|
34
|
-
<a href="_index.html">Index (K)</a> »
|
35
|
-
|
36
|
-
|
37
|
-
<span class="title">Kernel</span>
|
38
|
-
|
39
|
-
|
40
|
-
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
-
</div>
|
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>
|
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>
|
63
|
-
|
64
|
-
<iframe id="search_frame"></iframe>
|
65
|
-
|
66
|
-
<div id="content"><h1>Module: Kernel
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
</h1>
|
71
|
-
|
72
|
-
<dl class="box">
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<dt class="r1 last">Defined in:</dt>
|
82
|
-
<dd class="r1 last">lib/shenanigans/kernel/fn.rb<span class="defines">,<br />
|
83
|
-
lib/shenanigans/kernel/with.rb,<br /> lib/shenanigans/kernel/prompt.rb,<br /> lib/shenanigans/kernel/require_optional.rb</span>
|
84
|
-
</dd>
|
85
|
-
|
86
|
-
</dl>
|
87
|
-
<div class="clear"></div>
|
88
|
-
|
89
|
-
|
90
|
-
<h2>Constant Summary</h2>
|
91
|
-
|
92
|
-
<dl class="constants">
|
93
|
-
|
94
|
-
<dt id="CONVERSIONS-constant" class="">CONVERSIONS =
|
95
|
-
<div class="docstring">
|
96
|
-
<div class="discussion">
|
97
|
-
|
98
|
-
<p>Currently only used by <code>prompt</code>: <code>:to_i</code>,
|
99
|
-
<code>:to_f</code>, <code>:to_r</code>, <code>:to_sym</code>,
|
100
|
-
<code>:to_c</code></p>
|
101
|
-
|
102
|
-
|
103
|
-
</div>
|
104
|
-
</div>
|
105
|
-
<div class="tags">
|
106
|
-
|
107
|
-
|
108
|
-
</div>
|
109
|
-
</dt>
|
110
|
-
<dd><pre class="code"><span class='lbracket'>[</span><span class='symbol'>:to_i</span><span class='comma'>,</span> <span class='symbol'>:to_f</span><span class='comma'>,</span> <span class='symbol'>:to_r</span><span class='comma'>,</span> <span class='symbol'>:to_sym</span><span class='comma'>,</span> <span class='symbol'>:to_c</span><span class='rbracket'>]</span></pre></dd>
|
111
|
-
|
112
|
-
</dl>
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
<h2>
|
123
|
-
Instance Method Summary
|
124
|
-
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
125
|
-
</h2>
|
126
|
-
|
127
|
-
<ul class="summary">
|
128
|
-
|
129
|
-
<li class="private ">
|
130
|
-
<span class="summary_signature">
|
131
|
-
|
132
|
-
<a href="#fn-instance_method" title="#fn (instance method)">- (Object) <strong>fn</strong>(*funs) </a>
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
</span>
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
<span class="note title private">private</span>
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
<span class="summary_desc"><div class='inline'>
|
147
|
-
<p>Composes a list of functions.</p>
|
148
|
-
</div></span>
|
149
|
-
|
150
|
-
</li>
|
151
|
-
|
152
|
-
|
153
|
-
<li class="private ">
|
154
|
-
<span class="summary_signature">
|
155
|
-
|
156
|
-
<a href="#prompt-instance_method" title="#prompt (instance method)">- (Object) <strong>prompt</strong>(text = '', conversion = nil) </a>
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
</span>
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
<span class="note title private">private</span>
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
<span class="summary_desc"><div class='inline'>
|
171
|
-
<p>Displays a prompt and returns chomped input.</p>
|
172
|
-
</div></span>
|
173
|
-
|
174
|
-
</li>
|
175
|
-
|
176
|
-
|
177
|
-
<li class="private ">
|
178
|
-
<span class="summary_signature">
|
179
|
-
|
180
|
-
<a href="#require_optional-instance_method" title="#require_optional (instance method)">- (Object) <strong>require_optional</strong>(gem, &block) </a>
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
</span>
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
<span class="note title private">private</span>
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
<span class="summary_desc"><div class='inline'>
|
195
|
-
<p>Optionally require a gem.</p>
|
196
|
-
</div></span>
|
197
|
-
|
198
|
-
</li>
|
199
|
-
|
200
|
-
|
201
|
-
<li class="private ">
|
202
|
-
<span class="summary_signature">
|
203
|
-
|
204
|
-
<a href="#with-instance_method" title="#with (instance method)">- (Object) <strong>with</strong>(o, &blk) </a>
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
</span>
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
<span class="note title private">private</span>
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
<span class="summary_desc"><div class='inline'>
|
219
|
-
<p>A Pascal/ActionScript like with method.</p>
|
220
|
-
</div></span>
|
221
|
-
|
222
|
-
</li>
|
223
|
-
|
224
|
-
|
225
|
-
</ul>
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
<div id="instance_method_details" class="method_details_list">
|
231
|
-
<h2>Instance Method Details</h2>
|
232
|
-
|
233
|
-
|
234
|
-
<div class="method_details first">
|
235
|
-
<h3 class="signature first" id="fn-instance_method">
|
236
|
-
|
237
|
-
- (<tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>) <strong>fn</strong>(*funs) <span class="extras">(private)</span>
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
</h3><div class="docstring">
|
244
|
-
<div class="discussion">
|
245
|
-
|
246
|
-
<p>Composes a list of functions. Functions can be specified as symbols or
|
247
|
-
lambdas.</p>
|
248
|
-
|
249
|
-
<pre class="ruby">[<span class="ruby-string">"foo bar"</span>, <span class="ruby-string">"baz qux"</span>].<span class="ruby-identifier">map</span> <span class="ruby-operator">&</span><span class="ruby-identifier">fn</span>(:<span class="ruby-identifier">split</span>, :<span class="ruby-identifier">last</span>)
|
250
|
-
<span class="ruby-comment">#=> ["bar", "qux"]</span>
|
251
|
-
|
252
|
-
(<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">3</span>).<span class="ruby-identifier">map</span> <span class="ruby-operator">&</span><span class="ruby-identifier">fn</span>(:<span class="ruby-keyword">next</span>, <span class="ruby-operator">-</span><span class="ruby-operator">></span> <span class="ruby-identifier">x</span> { <span class="ruby-identifier">x</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">x</span> }, <span class="ruby-operator">-</span><span class="ruby-operator">></span> <span class="ruby-identifier">x</span> { <span class="ruby-identifier">x</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-value">2</span> } )
|
253
|
-
<span class="ruby-comment">#=> [2.0, 4.5, 8.0]</span>
|
254
|
-
</pre>
|
255
|
-
|
256
|
-
|
257
|
-
</div>
|
258
|
-
</div>
|
259
|
-
<div class="tags">
|
260
|
-
|
261
|
-
|
262
|
-
</div><table class="source_code">
|
263
|
-
<tr>
|
264
|
-
<td>
|
265
|
-
<pre class="lines">
|
266
|
-
|
267
|
-
|
268
|
-
9
|
269
|
-
10
|
270
|
-
11
|
271
|
-
12
|
272
|
-
13
|
273
|
-
14
|
274
|
-
15</pre>
|
275
|
-
</td>
|
276
|
-
<td>
|
277
|
-
<pre class="code"><span class="info file"># File 'lib/shenanigans/kernel/fn.rb', line 9</span>
|
278
|
-
|
279
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_fn'>fn</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_funs'>funs</span><span class='rparen'>)</span>
|
280
|
-
<span class='tlambda'>-></span> <span class='id identifier rubyid_x'>x</span> <span class='kw'>do</span>
|
281
|
-
<span class='id identifier rubyid_funs'>funs</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='comma'>,</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span>
|
282
|
-
<span class='const'>Proc</span> <span class='op'>===</span> <span class='id identifier rubyid_f'>f</span> <span class='op'>?</span> <span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='rparen'>)</span>
|
283
|
-
<span class='kw'>end</span>
|
284
|
-
<span class='kw'>end</span>
|
285
|
-
<span class='kw'>end</span></pre>
|
286
|
-
</td>
|
287
|
-
</tr>
|
288
|
-
</table>
|
289
|
-
</div>
|
290
|
-
|
291
|
-
<div class="method_details ">
|
292
|
-
<h3 class="signature " id="prompt-instance_method">
|
293
|
-
|
294
|
-
- (<tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>) <strong>prompt</strong>(text = '', conversion = nil) <span class="extras">(private)</span>
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
</h3><div class="docstring">
|
301
|
-
<div class="discussion">
|
302
|
-
|
303
|
-
<p>Displays a prompt and returns chomped input. Modelled after the Python
|
304
|
-
method <code>raw_input</code>, but also can be supplied with an optional
|
305
|
-
conversion method.</p>
|
306
|
-
|
307
|
-
<pre class="ruby"><span class="ruby-identifier">prompt</span>(<span class="ruby-string">"Prompt> "</span>)
|
308
|
-
<span class="ruby-constant">Prompt</span><span class="ruby-operator">></span> <span class="ruby-value">12</span>
|
309
|
-
<span class="ruby-comment">#=> "12"</span>
|
310
|
-
|
311
|
-
<span class="ruby-identifier">prompt</span>(<span class="ruby-string">"Prompt> "</span>, :<span class="ruby-identifier">to_f</span>)
|
312
|
-
<span class="ruby-constant">Prompt</span><span class="ruby-operator">></span> <span class="ruby-value">12</span>
|
313
|
-
<span class="ruby-comment">#=> 12.0</span>
|
314
|
-
</pre>
|
315
|
-
|
316
|
-
|
317
|
-
</div>
|
318
|
-
</div>
|
319
|
-
<div class="tags">
|
320
|
-
|
321
|
-
|
322
|
-
</div><table class="source_code">
|
323
|
-
<tr>
|
324
|
-
<td>
|
325
|
-
<pre class="lines">
|
326
|
-
|
327
|
-
|
328
|
-
17
|
329
|
-
18
|
330
|
-
19
|
331
|
-
20
|
332
|
-
21</pre>
|
333
|
-
</td>
|
334
|
-
<td>
|
335
|
-
<pre class="code"><span class="info file"># File 'lib/shenanigans/kernel/prompt.rb', line 17</span>
|
336
|
-
|
337
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_prompt'>prompt</span><span class='lparen'>(</span><span class='id identifier rubyid_text'>text</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_conversion'>conversion</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
|
338
|
-
<span class='id identifier rubyid_print'>print</span> <span class='id identifier rubyid_text'>text</span> <span class='kw'>unless</span> <span class='id identifier rubyid_text'>text</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
339
|
-
<span class='id identifier rubyid_input'>input</span> <span class='op'>=</span> <span class='id identifier rubyid_gets'>gets</span><span class='period'>.</span><span class='id identifier rubyid_chomp'>chomp</span>
|
340
|
-
<span class='const'>CONVERSIONS</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_conversion'>conversion</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_input'>input</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_conversion'>conversion</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_input'>input</span>
|
341
|
-
<span class='kw'>end</span></pre>
|
342
|
-
</td>
|
343
|
-
</tr>
|
344
|
-
</table>
|
345
|
-
</div>
|
346
|
-
|
347
|
-
<div class="method_details ">
|
348
|
-
<h3 class="signature " id="require_optional-instance_method">
|
349
|
-
|
350
|
-
- (<tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>) <strong>require_optional</strong>(gem, &block) <span class="extras">(private)</span>
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
</h3><div class="docstring">
|
357
|
-
<div class="discussion">
|
358
|
-
|
359
|
-
<p>Optionally require a gem. If it is not available, <code>nil</code> will be
|
360
|
-
returned. Alternatively, a block can be provided with code to run.</p>
|
361
|
-
|
362
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'non_existent'</span>
|
363
|
-
<span class="ruby-comment">#=> nil</span>
|
364
|
-
|
365
|
-
<span class="ruby-identifier">require</span> <span class="ruby-string">'non_existent'</span> <span class="ruby-keyword">do</span>
|
366
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">'Something went wrong'</span>
|
367
|
-
<span class="ruby-keyword">end</span>
|
368
|
-
<span class="ruby-comment">#=> Outputs 'Something went wrong'</span>
|
369
|
-
</pre>
|
370
|
-
|
371
|
-
|
372
|
-
</div>
|
373
|
-
</div>
|
374
|
-
<div class="tags">
|
375
|
-
|
376
|
-
|
377
|
-
</div><table class="source_code">
|
378
|
-
<tr>
|
379
|
-
<td>
|
380
|
-
<pre class="lines">
|
381
|
-
|
382
|
-
|
383
|
-
12
|
384
|
-
13
|
385
|
-
14
|
386
|
-
15
|
387
|
-
16</pre>
|
388
|
-
</td>
|
389
|
-
<td>
|
390
|
-
<pre class="code"><span class="info file"># File 'lib/shenanigans/kernel/require_optional.rb', line 12</span>
|
391
|
-
|
392
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_require_optional'>require_optional</span><span class='lparen'>(</span><span class='id identifier rubyid_gem'>gem</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
393
|
-
<span class='id identifier rubyid_require'>require</span> <span class='id identifier rubyid_gem'>gem</span>
|
394
|
-
<span class='kw'>rescue</span> <span class='const'>LoadError</span>
|
395
|
-
<span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='kw'>if</span> <span class='id identifier rubyid_block'>block</span>
|
396
|
-
<span class='kw'>end</span></pre>
|
397
|
-
</td>
|
398
|
-
</tr>
|
399
|
-
</table>
|
400
|
-
</div>
|
401
|
-
|
402
|
-
<div class="method_details ">
|
403
|
-
<h3 class="signature " id="with-instance_method">
|
404
|
-
|
405
|
-
- (<tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt>) <strong>with</strong>(o, &blk) <span class="extras">(private)</span>
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
</h3><div class="docstring">
|
412
|
-
<div class="discussion">
|
413
|
-
|
414
|
-
<p>A Pascal/ActionScript like <code>with</code> method. Yields its argument to
|
415
|
-
the provided block and then returns it.</p>
|
416
|
-
|
417
|
-
<pre class="ruby"><span class="ruby-identifier">with</span>([]) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
|
418
|
-
<span class="ruby-identifier">a</span> <span class="ruby-operator"><<</span> <span class="ruby-string">"a"</span>
|
419
|
-
<span class="ruby-identifier">a</span> <span class="ruby-operator"><<</span> <span class="ruby-string">"b"</span>
|
420
|
-
<span class="ruby-keyword">end</span>
|
421
|
-
<span class="ruby-comment">#=> ["a", "b"]</span>
|
422
|
-
</pre>
|
423
|
-
|
424
|
-
|
425
|
-
</div>
|
426
|
-
</div>
|
427
|
-
<div class="tags">
|
428
|
-
|
429
|
-
|
430
|
-
</div><table class="source_code">
|
431
|
-
<tr>
|
432
|
-
<td>
|
433
|
-
<pre class="lines">
|
434
|
-
|
435
|
-
|
436
|
-
9
|
437
|
-
10
|
438
|
-
11</pre>
|
439
|
-
</td>
|
440
|
-
<td>
|
441
|
-
<pre class="code"><span class="info file"># File 'lib/shenanigans/kernel/with.rb', line 9</span>
|
442
|
-
|
443
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_o'>o</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
|
444
|
-
<span class='id identifier rubyid_o'>o</span><span class='period'>.</span><span class='id identifier rubyid_tap'>tap</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
|
445
|
-
<span class='kw'>end</span></pre>
|
446
|
-
</td>
|
447
|
-
</tr>
|
448
|
-
</table>
|
449
|
-
</div>
|
450
|
-
|
451
|
-
</div>
|
452
|
-
|
453
|
-
</div>
|
454
|
-
|
455
|
-
<div id="footer">
|
456
|
-
Generated on Tue Dec 31 15:41:29 2013 by
|
457
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
458
|
-
0.8.7.3 (ruby-2.0.0).
|
459
|
-
</div>
|
460
|
-
|
461
|
-
</body>
|
462
|
-
</html>
|