shenanigans 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -3
- data/README.rdoc +1 -1
- data/doc/Array.html +423 -202
- data/doc/Fixnum.html +155 -140
- data/doc/Hash.html +305 -206
- data/doc/Kernel.html +360 -249
- data/doc/Module.html +181 -153
- data/doc/Object.html +210 -201
- data/doc/String.html +166 -139
- data/doc/_index.html +188 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +338 -0
- data/doc/file.README.html +162 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +62 -80
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -18
- data/doc/method_list.html +149 -0
- data/doc/top-level-namespace.html +114 -0
- data/lib/shenanigans.rb +3 -1
- data/lib/shenanigans/array.rb +3 -3
- data/lib/shenanigans/array/reductions.rb +29 -0
- data/lib/shenanigans/kernel.rb +4 -4
- data/lib/shenanigans/module.rb +1 -1
- data/lib/shenanigans/object.rb +2 -2
- data/lib/shenanigans/string.rb +1 -1
- data/test/array/test_reductions.rb +27 -0
- metadata +16 -36
- data/doc/README_rdoc.html +0 -199
- data/doc/created.rid +0 -25
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/js/darkfish.js +0 -155
- data/doc/js/navigation.js +0 -142
- data/doc/js/search.js +0 -94
- data/doc/js/search_index.js +0 -1
- data/doc/js/searcher.js +0 -228
- data/doc/rdoc.css +0 -595
- data/doc/table_of_contents.html +0 -114
data/doc/Kernel.html
CHANGED
@@ -1,178 +1,249 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta content="text/html; charset=
|
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>
|
6
12
|
|
7
|
-
<
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
8
14
|
|
9
|
-
<link
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
10
16
|
|
11
|
-
<script type="text/javascript">
|
12
|
-
|
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
|
-
<
|
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
|
-
|
35
|
-
<
|
36
|
-
<
|
37
|
-
<
|
38
|
-
|
39
|
-
</
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
+
|
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
|
-
|
49
|
-
<nav id="file-list-section" class="section">
|
50
|
-
<h3 class="section-header">Defined In</h3>
|
51
|
-
<ul>
|
52
|
-
<li>lib/shenanigans/kernel/fn.rb
|
53
|
-
<li>lib/shenanigans/kernel/prompt.rb
|
54
|
-
<li>lib/shenanigans/kernel/require_optional.rb
|
55
|
-
<li>lib/shenanigans/kernel/with.rb
|
56
|
-
</ul>
|
57
|
-
</nav>
|
64
|
+
<iframe id="search_frame"></iframe>
|
58
65
|
|
59
|
-
|
60
|
-
|
66
|
+
<div id="content"><h1>Module: Kernel
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
61
71
|
|
62
|
-
|
63
|
-
|
64
|
-
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
|
65
75
|
|
76
|
+
|
66
77
|
|
67
|
-
|
68
|
-
|
69
|
-
|
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>
|
70
88
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<li ><a href="#method-i-with">#with</a>
|
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">
|
80
97
|
|
81
|
-
|
82
|
-
</
|
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>
|
83
101
|
|
84
|
-
</div>
|
85
102
|
|
86
|
-
|
87
|
-
|
88
|
-
|
103
|
+
</div>
|
104
|
+
</div>
|
105
|
+
<div class="tags">
|
106
|
+
|
89
107
|
|
90
|
-
|
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>
|
91
113
|
|
92
|
-
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
93
121
|
|
94
|
-
|
95
|
-
|
122
|
+
<h2>
|
123
|
+
Instance Method Summary
|
124
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
125
|
+
</h2>
|
96
126
|
|
97
|
-
<
|
98
|
-
|
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
|
+
|
99
134
|
|
100
|
-
|
135
|
+
|
136
|
+
</span>
|
101
137
|
|
102
|
-
<li><a href="./Array.html">Array</a>
|
103
138
|
|
104
|
-
<li><a href="./Fixnum.html">Fixnum</a>
|
105
139
|
|
106
|
-
|
140
|
+
<span class="note title private">private</span>
|
107
141
|
|
108
|
-
<li><a href="./Kernel.html">Kernel</a>
|
109
142
|
|
110
|
-
<li><a href="./Module.html">Module</a>
|
111
143
|
|
112
|
-
|
144
|
+
|
113
145
|
|
114
|
-
<
|
146
|
+
<span class="summary_desc"><div class='inline'>
|
147
|
+
<p>Composes a list of functions.</p>
|
148
|
+
</div></span>
|
115
149
|
|
116
|
-
|
117
|
-
</nav>
|
118
|
-
|
119
|
-
</div>
|
120
|
-
</nav>
|
150
|
+
</li>
|
121
151
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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>
|
126
157
|
|
127
|
-
</div><!-- description -->
|
128
158
|
|
159
|
+
|
160
|
+
</span>
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
<span class="note title private">private</span>
|
129
165
|
|
130
166
|
|
131
167
|
|
132
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
133
|
-
|
134
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>
|
135
181
|
|
136
182
|
|
137
183
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
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
|
+
|
149
200
|
|
150
|
-
|
151
|
-
|
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>
|
152
205
|
|
153
206
|
|
154
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>
|
155
232
|
|
156
|
-
<!-- Methods -->
|
157
233
|
|
158
|
-
|
159
|
-
|
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
|
+
|
160
239
|
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
</h3><div class="docstring">
|
244
|
+
<div class="discussion">
|
161
245
|
|
162
|
-
|
163
|
-
|
164
|
-
<div class="method-heading">
|
165
|
-
<span class="method-name">fn</span><span
|
166
|
-
class="method-args">(*funs)</span>
|
167
|
-
|
168
|
-
<span class="method-click-advice">click to toggle source</span>
|
169
|
-
|
170
|
-
</div>
|
171
|
-
|
172
|
-
|
173
|
-
<div class="method-description">
|
174
|
-
|
175
|
-
<p>Composes a list of functions. Functions can be specified as symbols or
|
246
|
+
<p>Composes a list of functions. Functions can be specified as symbols or
|
176
247
|
lambdas.</p>
|
177
248
|
|
178
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>)
|
@@ -181,43 +252,55 @@ lambdas.</p>
|
|
181
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> } )
|
182
253
|
<span class="ruby-comment">#=> [2.0, 4.5, 8.0]</span>
|
183
254
|
</pre>
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
<div class="method-source-code" id="fn-source">
|
189
|
-
<pre><span class="ruby-comment"># File lib/shenanigans/kernel/fn.rb, line 9</span>
|
190
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fn</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">funs</span>)
|
191
|
-
<span class="ruby-operator">-</span><span class="ruby-operator">></span> <span class="ruby-identifier">x</span> <span class="ruby-keyword">do</span>
|
192
|
-
<span class="ruby-identifier">funs</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">x</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span>,<span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
193
|
-
<span class="ruby-constant">Proc</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">f</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">v</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">f</span>)
|
194
|
-
<span class="ruby-keyword">end</span>
|
195
|
-
<span class="ruby-keyword">end</span>
|
196
|
-
<span class="ruby-keyword">end</span></pre>
|
197
|
-
</div><!-- fn-source -->
|
198
|
-
|
199
|
-
</div>
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
</div><!-- fn-method -->
|
205
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>
|
206
290
|
|
207
|
-
<div
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
<p>Displays a prompt and returns chomped input. Modelled after the Python
|
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
|
221
304
|
method <code>raw_input</code>, but also can be supplied with an optional
|
222
305
|
conversion method.</p>
|
223
306
|
|
@@ -229,41 +312,51 @@ conversion method.</p>
|
|
229
312
|
<span class="ruby-constant">Prompt</span><span class="ruby-operator">></span> <span class="ruby-value">12</span>
|
230
313
|
<span class="ruby-comment">#=> 12.0</span>
|
231
314
|
</pre>
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
<div class="method-source-code" id="prompt-source">
|
237
|
-
<pre><span class="ruby-comment"># File lib/shenanigans/kernel/prompt.rb, line 17</span>
|
238
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">prompt</span>(<span class="ruby-identifier">text</span>=<span class="ruby-string">''</span>, <span class="ruby-identifier">conversion</span>=<span class="ruby-keyword">nil</span>)
|
239
|
-
<span class="ruby-identifier">print</span> <span class="ruby-identifier">text</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">empty?</span>
|
240
|
-
<span class="ruby-identifier">input</span> = <span class="ruby-identifier">gets</span>.<span class="ruby-identifier">chomp</span>
|
241
|
-
<span class="ruby-constant">CONVERSIONS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">conversion</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">input</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">conversion</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">input</span>
|
242
|
-
<span class="ruby-keyword">end</span></pre>
|
243
|
-
</div><!-- prompt-source -->
|
244
|
-
|
245
|
-
</div>
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
</div><!-- prompt-method -->
|
251
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">
|
252
358
|
|
253
|
-
|
254
|
-
|
255
|
-
<div class="method-heading">
|
256
|
-
<span class="method-name">require_optional</span><span
|
257
|
-
class="method-args">(gem, &block)</span>
|
258
|
-
|
259
|
-
<span class="method-click-advice">click to toggle source</span>
|
260
|
-
|
261
|
-
</div>
|
262
|
-
|
263
|
-
|
264
|
-
<div class="method-description">
|
265
|
-
|
266
|
-
<p>Optionally require a gem. If it is not available, <code>nil</code> will be
|
359
|
+
<p>Optionally require a gem. If it is not available, <code>nil</code> will be
|
267
360
|
returned. Alternatively, a block can be provided with code to run.</p>
|
268
361
|
|
269
362
|
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'non_existent'</span>
|
@@ -274,41 +367,51 @@ returned. Alternatively, a block can be provided with code to run.</p>
|
|
274
367
|
<span class="ruby-keyword">end</span>
|
275
368
|
<span class="ruby-comment">#=> Outputs 'Something went wrong'</span>
|
276
369
|
</pre>
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
<div class="method-source-code" id="require_optional-source">
|
282
|
-
<pre><span class="ruby-comment"># File lib/shenanigans/kernel/require_optional.rb, line 12</span>
|
283
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">require_optional</span>(<span class="ruby-identifier">gem</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
284
|
-
<span class="ruby-identifier">require</span> <span class="ruby-identifier">gem</span>
|
285
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">LoadError</span>
|
286
|
-
<span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block</span>
|
287
|
-
<span class="ruby-keyword">end</span></pre>
|
288
|
-
</div><!-- require_optional-source -->
|
289
|
-
|
290
|
-
</div>
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
</div><!-- require_optional-method -->
|
296
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>
|
297
401
|
|
298
|
-
<div
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
<p>A Pascal/ActionScript like <code>with</code> method. Yields its argument to
|
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
|
312
415
|
the provided block and then returns it.</p>
|
313
416
|
|
314
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>
|
@@ -317,35 +420,43 @@ the provided block and then returns it.</p>
|
|
317
420
|
<span class="ruby-keyword">end</span>
|
318
421
|
<span class="ruby-comment">#=> ["a", "b"]</span>
|
319
422
|
</pre>
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
<div class="method-source-code" id="with-source">
|
325
|
-
<pre><span class="ruby-comment"># File lib/shenanigans/kernel/with.rb, line 9</span>
|
326
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">with</span>(<span class="ruby-identifier">o</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">blk</span>)
|
327
|
-
<span class="ruby-identifier">o</span>.<span class="ruby-identifier">tap</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">blk</span>)
|
328
|
-
<span class="ruby-keyword">end</span></pre>
|
329
|
-
</div><!-- with-source -->
|
330
|
-
|
331
|
-
</div>
|
332
|
-
|
333
|
-
|
334
423
|
|
335
|
-
|
336
|
-
</div><!-- with-method -->
|
337
424
|
|
338
|
-
|
339
|
-
|
425
|
+
</div>
|
426
|
+
</div>
|
427
|
+
<div class="tags">
|
340
428
|
|
341
|
-
</section><!-- 5Buntitled-5D -->
|
342
429
|
|
343
|
-
</div
|
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>
|
344
452
|
|
453
|
+
</div>
|
345
454
|
|
346
|
-
<
|
347
|
-
|
348
|
-
<
|
349
|
-
|
350
|
-
</
|
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>
|
351
460
|
|
461
|
+
</body>
|
462
|
+
</html>
|