shenanigans 1.0.13 → 1.0.16
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 +4 -4
- 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 +7 -6
- data/lib/shenanigans/kernel/prompt.rb +6 -7
- data/lib/shenanigans/kernel/require_optional.rb +8 -8
- data/lib/shenanigans/kernel/with.rb +4 -3
- data/lib/shenanigans/kernel.rb +4 -4
- data/lib/shenanigans/module/private_accessor.rb +6 -6
- 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 +4 -3
- data/lib/shenanigans/string/in_groups_of.rb +4 -6
- data/lib/shenanigans/string.rb +2 -2
- data/lib/shenanigans.rb +7 -7
- metadata +81 -51
- data/Gemfile +0 -8
- data/doc/Array.html +0 -519
- data/doc/Fixnum.html +0 -215
- data/doc/Hash.html +0 -417
- data/doc/Kernel.html +0 -460
- data/doc/Module.html +0 -237
- data/doc/Object.html +0 -286
- data/doc/String.html +0 -299
- data/doc/_index.html +0 -185
- data/doc/class_list.html +0 -51
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -58
- data/doc/css/style.css +0 -499
- data/doc/file.README.html +0 -160
- data/doc/file_list.html +0 -56
- data/doc/frames.html +0 -17
- data/doc/index.html +0 -160
- data/doc/js/app.js +0 -248
- data/doc/js/full_list.js +0 -216
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -187
- data/doc/top-level-namespace.html +0 -112
- 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_random_subarray.rb +0 -10
- 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/hash/test_has_shape_pred.rb +0 -40
- data/test/hash/test_to_ostruct.rb +0 -23
- data/test/kernel/test_fn.rb +0 -14
- data/test/kernel/test_prompt.rb +0 -27
- data/test/kernel/test_require_optional.rb +0 -17
- data/test/kernel/test_with.rb +0 -12
- data/test/module/test_private_accessor.rb +0 -21
- data/test/object/test_display.rb +0 -36
- data/test/object/test_it.rb +0 -10
- data/test/string/test_cmpi.rb +0 -10
- data/test/string/test_in_groups_of.rb +0 -11
data/doc/Kernel.html
DELETED
@@ -1,460 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
-
<title>
|
7
|
-
Module: Kernel
|
8
|
-
|
9
|
-
— Documentation by YARD 0.9.12
|
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
|
-
pathId = "Kernel";
|
19
|
-
relpath = '';
|
20
|
-
</script>
|
21
|
-
|
22
|
-
|
23
|
-
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
-
|
25
|
-
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
-
|
27
|
-
|
28
|
-
</head>
|
29
|
-
<body>
|
30
|
-
<div class="nav_wrap">
|
31
|
-
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
-
<div id="resizer"></div>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div id="main" tabindex="-1">
|
36
|
-
<div id="header">
|
37
|
-
<div id="menu">
|
38
|
-
|
39
|
-
<a href="_index.html">Index (K)</a> »
|
40
|
-
|
41
|
-
|
42
|
-
<span class="title">Kernel</span>
|
43
|
-
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<div id="search">
|
47
|
-
|
48
|
-
<a class="full_list_link" id="class_list_link"
|
49
|
-
href="class_list.html">
|
50
|
-
|
51
|
-
<svg width="24" height="24">
|
52
|
-
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
-
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
-
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
-
</svg>
|
56
|
-
</a>
|
57
|
-
|
58
|
-
</div>
|
59
|
-
<div class="clear"></div>
|
60
|
-
</div>
|
61
|
-
|
62
|
-
<div id="content"><h1>Module: Kernel
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
</h1>
|
67
|
-
<div class="box_info">
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<dl>
|
80
|
-
<dt>Defined in:</dt>
|
81
|
-
<dd>lib/shenanigans/kernel/fn.rb<span class="defines">,<br />
|
82
|
-
lib/shenanigans/kernel/with.rb,<br /> lib/shenanigans/kernel/prompt.rb,<br /> lib/shenanigans/kernel/require_optional.rb</span>
|
83
|
-
</dd>
|
84
|
-
</dl>
|
85
|
-
|
86
|
-
</div>
|
87
|
-
|
88
|
-
|
89
|
-
<h2>Constant Summary</h2>
|
90
|
-
<dl class="constants">
|
91
|
-
|
92
|
-
<dt id="CONVERSIONS-constant" class="">CONVERSIONS =
|
93
|
-
<div class="docstring">
|
94
|
-
<div class="discussion">
|
95
|
-
|
96
|
-
<p>Currently only used by <code>prompt</code>: <code>:to_i</code>,
|
97
|
-
<code>:to_f</code>, <code>:to_r</code>, <code>:to_sym</code>,
|
98
|
-
<code>:to_c</code></p>
|
99
|
-
|
100
|
-
|
101
|
-
</div>
|
102
|
-
</div>
|
103
|
-
<div class="tags">
|
104
|
-
|
105
|
-
|
106
|
-
</div>
|
107
|
-
</dt>
|
108
|
-
<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>
|
109
|
-
|
110
|
-
</dl>
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
<h2>
|
120
|
-
Instance Method Summary
|
121
|
-
<small><a href="#" class="summary_toggle">collapse</a></small>
|
122
|
-
</h2>
|
123
|
-
|
124
|
-
<ul class="summary">
|
125
|
-
|
126
|
-
<li class="private ">
|
127
|
-
<span class="summary_signature">
|
128
|
-
|
129
|
-
<a href="#fn-instance_method" title="#fn (instance method)">#<strong>fn</strong>(*funs) ⇒ Object </a>
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
</span>
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
<span class="note title private">private</span>
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
<span class="summary_desc"><div class='inline'>
|
144
|
-
<p>Composes a list of functions.</p>
|
145
|
-
</div></span>
|
146
|
-
|
147
|
-
</li>
|
148
|
-
|
149
|
-
|
150
|
-
<li class="private ">
|
151
|
-
<span class="summary_signature">
|
152
|
-
|
153
|
-
<a href="#prompt-instance_method" title="#prompt (instance method)">#<strong>prompt</strong>(text = '', conversion = nil) ⇒ Object </a>
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
</span>
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
<span class="note title private">private</span>
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
<span class="summary_desc"><div class='inline'>
|
168
|
-
<p>Displays a prompt and returns chomped input.</p>
|
169
|
-
</div></span>
|
170
|
-
|
171
|
-
</li>
|
172
|
-
|
173
|
-
|
174
|
-
<li class="private ">
|
175
|
-
<span class="summary_signature">
|
176
|
-
|
177
|
-
<a href="#require_optional-instance_method" title="#require_optional (instance method)">#<strong>require_optional</strong>(gem, &block) ⇒ Object </a>
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
</span>
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
<span class="note title private">private</span>
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
<span class="summary_desc"><div class='inline'>
|
192
|
-
<p>Optionally require a gem.</p>
|
193
|
-
</div></span>
|
194
|
-
|
195
|
-
</li>
|
196
|
-
|
197
|
-
|
198
|
-
<li class="private ">
|
199
|
-
<span class="summary_signature">
|
200
|
-
|
201
|
-
<a href="#with-instance_method" title="#with (instance method)">#<strong>with</strong>(o, &blk) ⇒ Object </a>
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
</span>
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
<span class="note title private">private</span>
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
<span class="summary_desc"><div class='inline'>
|
216
|
-
<p>A Pascal/ActionScript like <code>with</code> method.</p>
|
217
|
-
</div></span>
|
218
|
-
|
219
|
-
</li>
|
220
|
-
|
221
|
-
|
222
|
-
</ul>
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
<div id="instance_method_details" class="method_details_list">
|
228
|
-
<h2>Instance Method Details</h2>
|
229
|
-
|
230
|
-
|
231
|
-
<div class="method_details first">
|
232
|
-
<h3 class="signature first" id="fn-instance_method">
|
233
|
-
|
234
|
-
#<strong>fn</strong>(*funs) ⇒ <tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt> <span class="extras">(private)</span>
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
</h3><div class="docstring">
|
241
|
-
<div class="discussion">
|
242
|
-
|
243
|
-
<p>Composes a list of functions. Functions can be specified as symbols or
|
244
|
-
lambdas.</p>
|
245
|
-
|
246
|
-
<pre class="code ruby"><code class="ruby"><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>foo bar</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>baz qux</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='op'>&</span><span class='id identifier rubyid_fn'>fn</span><span class='lparen'>(</span><span class='symbol'>:split</span><span class='comma'>,</span> <span class='symbol'>:last</span><span class='rparen'>)</span>
|
247
|
-
<span class='comment'>#=> ["bar", "qux"]
|
248
|
-
</span>
|
249
|
-
<span class='lparen'>(</span><span class='int'>1</span><span class='op'>..</span><span class='int'>3</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='op'>&</span><span class='id identifier rubyid_fn'>fn</span><span class='lparen'>(</span><span class='symbol'>:next</span><span class='comma'>,</span> <span class='tlambda'>-></span> <span class='id identifier rubyid_x'>x</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_x'>x</span> <span class='op'>*</span> <span class='id identifier rubyid_x'>x</span> <span class='rbrace'>}</span><span class='comma'>,</span> <span class='tlambda'>-></span> <span class='id identifier rubyid_x'>x</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_x'>x</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span> <span class='op'>/</span> <span class='int'>2</span> <span class='rbrace'>}</span> <span class='rparen'>)</span>
|
250
|
-
<span class='comment'>#=> [2.0, 4.5, 8.0]
|
251
|
-
</span></code></pre>
|
252
|
-
|
253
|
-
|
254
|
-
</div>
|
255
|
-
</div>
|
256
|
-
<div class="tags">
|
257
|
-
|
258
|
-
|
259
|
-
</div><table class="source_code">
|
260
|
-
<tr>
|
261
|
-
<td>
|
262
|
-
<pre class="lines">
|
263
|
-
|
264
|
-
|
265
|
-
9
|
266
|
-
10
|
267
|
-
11
|
268
|
-
12
|
269
|
-
13
|
270
|
-
14
|
271
|
-
15</pre>
|
272
|
-
</td>
|
273
|
-
<td>
|
274
|
-
<pre class="code"><span class="info file"># File 'lib/shenanigans/kernel/fn.rb', line 9</span>
|
275
|
-
|
276
|
-
<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>
|
277
|
-
<span class='tlambda'>-></span> <span class='id identifier rubyid_x'>x</span> <span class='kw'>do</span>
|
278
|
-
<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>
|
279
|
-
<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>
|
280
|
-
<span class='kw'>end</span>
|
281
|
-
<span class='kw'>end</span>
|
282
|
-
<span class='kw'>end</span></pre>
|
283
|
-
</td>
|
284
|
-
</tr>
|
285
|
-
</table>
|
286
|
-
</div>
|
287
|
-
|
288
|
-
<div class="method_details ">
|
289
|
-
<h3 class="signature " id="prompt-instance_method">
|
290
|
-
|
291
|
-
#<strong>prompt</strong>(text = '', conversion = nil) ⇒ <tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt> <span class="extras">(private)</span>
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
</h3><div class="docstring">
|
298
|
-
<div class="discussion">
|
299
|
-
|
300
|
-
<p>Displays a prompt and returns chomped input. Modelled after the Python
|
301
|
-
method <code>raw_input</code>, but also can be supplied with an optional
|
302
|
-
conversion method.</p>
|
303
|
-
|
304
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_prompt'>prompt</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Prompt> </span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
305
|
-
<span class='const'>Prompt</span><span class='op'>></span> <span class='int'>12</span>
|
306
|
-
<span class='comment'>#=> "12"
|
307
|
-
</span>
|
308
|
-
<span class='id identifier rubyid_prompt'>prompt</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Prompt> </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='symbol'>:to_f</span><span class='rparen'>)</span>
|
309
|
-
<span class='const'>Prompt</span><span class='op'>></span> <span class='int'>12</span>
|
310
|
-
<span class='comment'>#=> 12.0
|
311
|
-
</span></code></pre>
|
312
|
-
|
313
|
-
|
314
|
-
</div>
|
315
|
-
</div>
|
316
|
-
<div class="tags">
|
317
|
-
|
318
|
-
|
319
|
-
</div><table class="source_code">
|
320
|
-
<tr>
|
321
|
-
<td>
|
322
|
-
<pre class="lines">
|
323
|
-
|
324
|
-
|
325
|
-
17
|
326
|
-
18
|
327
|
-
19
|
328
|
-
20
|
329
|
-
21</pre>
|
330
|
-
</td>
|
331
|
-
<td>
|
332
|
-
<pre class="code"><span class="info file"># File 'lib/shenanigans/kernel/prompt.rb', line 17</span>
|
333
|
-
|
334
|
-
<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>
|
335
|
-
<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>
|
336
|
-
<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>
|
337
|
-
<span class='const'><span class='object_link'><a href="#CONVERSIONS-constant" title="Kernel::CONVERSIONS (constant)">CONVERSIONS</a></span></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>
|
338
|
-
<span class='kw'>end</span></pre>
|
339
|
-
</td>
|
340
|
-
</tr>
|
341
|
-
</table>
|
342
|
-
</div>
|
343
|
-
|
344
|
-
<div class="method_details ">
|
345
|
-
<h3 class="signature " id="require_optional-instance_method">
|
346
|
-
|
347
|
-
#<strong>require_optional</strong>(gem, &block) ⇒ <tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt> <span class="extras">(private)</span>
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
</h3><div class="docstring">
|
354
|
-
<div class="discussion">
|
355
|
-
|
356
|
-
<p>Optionally require a gem. If it is not available, <code>nil</code> will be
|
357
|
-
returned. Alternatively, a block can be provided with code to run.</p>
|
358
|
-
|
359
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>non_existent</span><span class='tstring_end'>'</span></span>
|
360
|
-
<span class='comment'>#=> nil
|
361
|
-
</span>
|
362
|
-
<span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>non_existent</span><span class='tstring_end'>'</span></span> <span class='kw'>do</span>
|
363
|
-
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Something went wrong</span><span class='tstring_end'>'</span></span>
|
364
|
-
<span class='kw'>end</span>
|
365
|
-
<span class='comment'>#=> Outputs 'Something went wrong'
|
366
|
-
</span></code></pre>
|
367
|
-
|
368
|
-
|
369
|
-
</div>
|
370
|
-
</div>
|
371
|
-
<div class="tags">
|
372
|
-
|
373
|
-
|
374
|
-
</div><table class="source_code">
|
375
|
-
<tr>
|
376
|
-
<td>
|
377
|
-
<pre class="lines">
|
378
|
-
|
379
|
-
|
380
|
-
12
|
381
|
-
13
|
382
|
-
14
|
383
|
-
15
|
384
|
-
16</pre>
|
385
|
-
</td>
|
386
|
-
<td>
|
387
|
-
<pre class="code"><span class="info file"># File 'lib/shenanigans/kernel/require_optional.rb', line 12</span>
|
388
|
-
|
389
|
-
<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>
|
390
|
-
<span class='id identifier rubyid_require'>require</span> <span class='id identifier rubyid_gem'>gem</span>
|
391
|
-
<span class='kw'>rescue</span> <span class='const'>LoadError</span>
|
392
|
-
<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>
|
393
|
-
<span class='kw'>end</span></pre>
|
394
|
-
</td>
|
395
|
-
</tr>
|
396
|
-
</table>
|
397
|
-
</div>
|
398
|
-
|
399
|
-
<div class="method_details ">
|
400
|
-
<h3 class="signature " id="with-instance_method">
|
401
|
-
|
402
|
-
#<strong>with</strong>(o, &blk) ⇒ <tt><span class='object_link'><a href="Object.html" title="Object (class)">Object</a></span></tt> <span class="extras">(private)</span>
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
</h3><div class="docstring">
|
409
|
-
<div class="discussion">
|
410
|
-
|
411
|
-
<p>A Pascal/ActionScript like <code>with</code> method. Yields its argument to
|
412
|
-
the provided block and then returns it.</p>
|
413
|
-
|
414
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='op'>|</span>
|
415
|
-
<span class='id identifier rubyid_a'>a</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>a</span><span class='tstring_end'>"</span></span>
|
416
|
-
<span class='id identifier rubyid_a'>a</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>b</span><span class='tstring_end'>"</span></span>
|
417
|
-
<span class='kw'>end</span>
|
418
|
-
<span class='comment'>#=> ["a", "b"]
|
419
|
-
</span></code></pre>
|
420
|
-
|
421
|
-
|
422
|
-
</div>
|
423
|
-
</div>
|
424
|
-
<div class="tags">
|
425
|
-
|
426
|
-
|
427
|
-
</div><table class="source_code">
|
428
|
-
<tr>
|
429
|
-
<td>
|
430
|
-
<pre class="lines">
|
431
|
-
|
432
|
-
|
433
|
-
9
|
434
|
-
10
|
435
|
-
11</pre>
|
436
|
-
</td>
|
437
|
-
<td>
|
438
|
-
<pre class="code"><span class="info file"># File 'lib/shenanigans/kernel/with.rb', line 9</span>
|
439
|
-
|
440
|
-
<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>
|
441
|
-
<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>
|
442
|
-
<span class='kw'>end</span></pre>
|
443
|
-
</td>
|
444
|
-
</tr>
|
445
|
-
</table>
|
446
|
-
</div>
|
447
|
-
|
448
|
-
</div>
|
449
|
-
|
450
|
-
</div>
|
451
|
-
|
452
|
-
<div id="footer">
|
453
|
-
Generated on Thu Feb 1 16:36:54 2018 by
|
454
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
455
|
-
0.9.12 (ruby-2.5.0).
|
456
|
-
</div>
|
457
|
-
|
458
|
-
</div>
|
459
|
-
</body>
|
460
|
-
</html>
|