shenanigans 1.0.8 → 1.0.9
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/doc/Array.html +20 -6
- data/doc/Fixnum.html +11 -3
- data/doc/Hash.html +26 -11
- data/doc/Kernel.html +75 -13
- data/doc/Module.html +208 -0
- data/doc/Object.html +20 -7
- data/doc/README_rdoc.html +31 -12
- data/doc/String.html +12 -4
- data/doc/created.rid +25 -22
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/index.html +15 -14
- data/doc/js/darkfish.js +9 -7
- data/doc/js/search_index.js +1 -1
- data/doc/rdoc.css +52 -0
- data/doc/table_of_contents.html +8 -1
- data/lib/shenanigans/kernel.rb +1 -0
- data/lib/shenanigans/kernel/fn.rb +2 -0
- data/lib/shenanigans/kernel/prompt.rb +1 -0
- data/lib/shenanigans/kernel/require_optional.rb +19 -0
- data/lib/shenanigans/kernel/with.rb +2 -0
- data/lib/shenanigans/module/private_accessor.rb +4 -2
- data/test/kernel/test_require_optional.rb +17 -0
- metadata +7 -3
- data/lib/shenanigans/README.mdown +0 -57
data/doc/Module.html
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>class Module - Shenanigans</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "./";
|
13
|
+
</script>
|
14
|
+
|
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
|
+
|
22
|
+
|
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>
|
32
|
+
|
33
|
+
|
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>
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
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/module/private_accessor.rb
|
53
|
+
</ul>
|
54
|
+
</nav>
|
55
|
+
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div id="class-metadata">
|
60
|
+
|
61
|
+
<nav id="parent-class-section" class="section">
|
62
|
+
<h3 class="section-header">Parent</h3>
|
63
|
+
|
64
|
+
<p class="link"><a href="Object.html">Object</a>
|
65
|
+
|
66
|
+
</nav>
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
<!-- Method Quickref -->
|
71
|
+
<nav id="method-list-section" class="section">
|
72
|
+
<h3 class="section-header">Methods</h3>
|
73
|
+
|
74
|
+
<ul class="link-list">
|
75
|
+
|
76
|
+
<li ><a href="#method-i-private_accessor">#private_accessor</a>
|
77
|
+
|
78
|
+
</ul>
|
79
|
+
</nav>
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
<div id="project-metadata">
|
84
|
+
<nav id="fileindex-section" class="section project-section">
|
85
|
+
<h3 class="section-header">Pages</h3>
|
86
|
+
|
87
|
+
<ul>
|
88
|
+
|
89
|
+
<li class="file"><a href="./README_rdoc.html">README</a>
|
90
|
+
|
91
|
+
</ul>
|
92
|
+
</nav>
|
93
|
+
|
94
|
+
<nav id="classindex-section" class="section project-section">
|
95
|
+
<h3 class="section-header">Class and Module Index</h3>
|
96
|
+
|
97
|
+
<ul class="link-list">
|
98
|
+
|
99
|
+
<li><a href="./Array.html">Array</a>
|
100
|
+
|
101
|
+
<li><a href="./Fixnum.html">Fixnum</a>
|
102
|
+
|
103
|
+
<li><a href="./Hash.html">Hash</a>
|
104
|
+
|
105
|
+
<li><a href="./Kernel.html">Kernel</a>
|
106
|
+
|
107
|
+
<li><a href="./Module.html">Module</a>
|
108
|
+
|
109
|
+
<li><a href="./Object.html">Object</a>
|
110
|
+
|
111
|
+
<li><a href="./String.html">String</a>
|
112
|
+
|
113
|
+
</ul>
|
114
|
+
</nav>
|
115
|
+
|
116
|
+
</div>
|
117
|
+
</nav>
|
118
|
+
|
119
|
+
<div id="documentation">
|
120
|
+
<h1 class="class">class Module</h1>
|
121
|
+
|
122
|
+
<div id="description" class="description">
|
123
|
+
|
124
|
+
</div><!-- description -->
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
<!-- Methods -->
|
139
|
+
|
140
|
+
<section id="private-instance-5Buntitled-5D-method-details" class="method-section section">
|
141
|
+
<h3 class="section-header">Private Instance Methods</h3>
|
142
|
+
|
143
|
+
|
144
|
+
<div id="method-i-private_accessor" class="method-detail ">
|
145
|
+
|
146
|
+
<div class="method-heading">
|
147
|
+
<span class="method-name">private_accessor</span><span
|
148
|
+
class="method-args">(*names)</span>
|
149
|
+
|
150
|
+
<span class="method-click-advice">click to toggle source</span>
|
151
|
+
|
152
|
+
</div>
|
153
|
+
|
154
|
+
|
155
|
+
<div class="method-description">
|
156
|
+
|
157
|
+
<p>Works like <code>attr_accessor</code> but generates private getter/setter
|
158
|
+
methods for class internal use only. Useful for enforcing Smalltalk-style
|
159
|
+
internal encapsulation.</p>
|
160
|
+
|
161
|
+
<p>For a more complete implementation of a similar feature see <a
|
162
|
+
href="https://github.com/citizen428/ivar_encapsulation">ivar_encapsulation</a>.</p>
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
<div class="method-source-code" id="private_accessor-source">
|
168
|
+
<pre><span class="ruby-comment"># File lib/shenanigans/module/private_accessor.rb, line 7</span>
|
169
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">private_accessor</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">names</span>)
|
170
|
+
<span class="ruby-identifier">names</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
|
171
|
+
<span class="ruby-identifier">instance_var_name</span> = <span class="ruby-node">"@#{name}"</span>
|
172
|
+
|
173
|
+
<span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">name</span>) <span class="ruby-keyword">do</span>
|
174
|
+
<span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-identifier">instance_var_name</span>)
|
175
|
+
<span class="ruby-keyword">end</span>
|
176
|
+
|
177
|
+
<span class="ruby-identifier">define_method</span>(<span class="ruby-node">"#{name}="</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
178
|
+
<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-identifier">instance_var_name</span>, <span class="ruby-identifier">value</span>)
|
179
|
+
<span class="ruby-keyword">end</span>
|
180
|
+
|
181
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value">:private</span>, <span class="ruby-identifier">name</span>)
|
182
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value">:private</span>, <span class="ruby-node">"#{name}="</span>)
|
183
|
+
<span class="ruby-keyword">end</span>
|
184
|
+
<span class="ruby-keyword">nil</span> <span class="ruby-comment"># like attr_accessor</span>
|
185
|
+
<span class="ruby-keyword">end</span></pre>
|
186
|
+
</div><!-- private_accessor-source -->
|
187
|
+
|
188
|
+
</div>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
</div><!-- private_accessor-method -->
|
194
|
+
|
195
|
+
|
196
|
+
</section><!-- private-instance-method-details -->
|
197
|
+
|
198
|
+
</section><!-- 5Buntitled-5D -->
|
199
|
+
|
200
|
+
</div><!-- documentation -->
|
201
|
+
|
202
|
+
|
203
|
+
<footer id="validator-badges">
|
204
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
205
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
|
206
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
207
|
+
</footer>
|
208
|
+
|
data/doc/Object.html
CHANGED
@@ -43,6 +43,8 @@
|
|
43
43
|
</nav>
|
44
44
|
|
45
45
|
|
46
|
+
|
47
|
+
|
46
48
|
<div id="file-metadata">
|
47
49
|
<nav id="file-list-section" class="section">
|
48
50
|
<h3 class="section-header">Defined In</h3>
|
@@ -65,17 +67,18 @@
|
|
65
67
|
</nav>
|
66
68
|
|
67
69
|
|
70
|
+
|
68
71
|
<!-- Method Quickref -->
|
69
72
|
<nav id="method-list-section" class="section">
|
70
73
|
<h3 class="section-header">Methods</h3>
|
71
74
|
|
72
75
|
<ul class="link-list">
|
73
76
|
|
74
|
-
<li><a href="#method-i-d">#d</a>
|
77
|
+
<li ><a href="#method-i-d">#d</a>
|
75
78
|
|
76
|
-
<li><a href="#method-i-display">#display</a>
|
79
|
+
<li ><a href="#method-i-display">#display</a>
|
77
80
|
|
78
|
-
<li><a href="#method-i-it">#it</a>
|
81
|
+
<li ><a href="#method-i-it">#it</a>
|
79
82
|
|
80
83
|
</ul>
|
81
84
|
</nav>
|
@@ -106,6 +109,8 @@
|
|
106
109
|
|
107
110
|
<li><a href="./Kernel.html">Kernel</a>
|
108
111
|
|
112
|
+
<li><a href="./Module.html">Module</a>
|
113
|
+
|
109
114
|
<li><a href="./Object.html">Object</a>
|
110
115
|
|
111
116
|
<li><a href="./String.html">String</a>
|
@@ -146,7 +151,7 @@
|
|
146
151
|
<div class="method-heading">
|
147
152
|
<span class="method-name">d</span><span
|
148
153
|
class="method-args">(new_line = true)</span>
|
149
|
-
|
154
|
+
|
150
155
|
</div>
|
151
156
|
|
152
157
|
|
@@ -154,6 +159,7 @@
|
|
154
159
|
|
155
160
|
|
156
161
|
|
162
|
+
|
157
163
|
|
158
164
|
|
159
165
|
</div>
|
@@ -173,7 +179,9 @@
|
|
173
179
|
<div class="method-heading">
|
174
180
|
<span class="method-name">display</span><span
|
175
181
|
class="method-args">(new_line = true)</span>
|
182
|
+
|
176
183
|
<span class="method-click-advice">click to toggle source</span>
|
184
|
+
|
177
185
|
</div>
|
178
186
|
|
179
187
|
|
@@ -191,6 +199,7 @@ otherwise.</p>
|
|
191
199
|
<span class="ruby-identifier">foo</span><span class="ruby-comment">#=> "foo"</span>
|
192
200
|
</pre>
|
193
201
|
|
202
|
+
|
194
203
|
|
195
204
|
|
196
205
|
<div class="method-source-code" id="display-source">
|
@@ -218,18 +227,22 @@ otherwise.</p>
|
|
218
227
|
<div class="method-heading">
|
219
228
|
<span class="method-name">it</span><span
|
220
229
|
class="method-args">()</span>
|
230
|
+
|
221
231
|
<span class="method-click-advice">click to toggle source</span>
|
232
|
+
|
222
233
|
</div>
|
223
234
|
|
224
235
|
|
225
236
|
<div class="method-description">
|
226
237
|
|
227
|
-
<p>An identity method that provides access to an object
|
238
|
+
<p>An identity method that provides access to an object's
|
239
|
+
<code>self</code>.</p>
|
228
240
|
|
229
|
-
<pre class="ruby">[<span class="ruby-value">1</span>,<span class="ruby-value">2</span>,<span class="ruby-value">3</span>,<span class="ruby-value">4</span>,<span class="ruby-value">5</span>,<span class="ruby-value">1</span>,<span class="ruby-value">2</span>,<span class="ruby-value">2</span>,<span class="ruby-value">3</span>].<span class="ruby-identifier">group_by</span>(
|
241
|
+
<pre class="ruby">[<span class="ruby-value">1</span>,<span class="ruby-value">2</span>,<span class="ruby-value">3</span>,<span class="ruby-value">4</span>,<span class="ruby-value">5</span>,<span class="ruby-value">1</span>,<span class="ruby-value">2</span>,<span class="ruby-value">2</span>,<span class="ruby-value">3</span>].<span class="ruby-identifier">group_by</span>(<span class="ruby-operator">&</span>:<span class="ruby-identifier">it</span>)
|
230
242
|
<span class="ruby-comment">#=> {1=>[1, 1], 2=>[2, 2, 2], 3=>[3, 3], 4=>[4], 5=>[5]}</span>
|
231
243
|
</pre>
|
232
244
|
|
245
|
+
|
233
246
|
|
234
247
|
|
235
248
|
<div class="method-source-code" id="it-source">
|
@@ -256,7 +269,7 @@ otherwise.</p>
|
|
256
269
|
|
257
270
|
<footer id="validator-badges">
|
258
271
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
259
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a>
|
272
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
|
260
273
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
261
274
|
</footer>
|
262
275
|
|
data/doc/README_rdoc.html
CHANGED
@@ -43,6 +43,23 @@
|
|
43
43
|
</nav>
|
44
44
|
|
45
45
|
|
46
|
+
|
47
|
+
<div id="table-of-contents">
|
48
|
+
<nav class="section">
|
49
|
+
<h3 class="section-header">Table of Contents</h3>
|
50
|
+
<ul>
|
51
|
+
<li><a href="#label-Shenanigans">Shenanigans</a>
|
52
|
+
<li><a href="#label-Introduction">Introduction</a>
|
53
|
+
<li><a href="#label-Installation">Installation</a>
|
54
|
+
<li><a href="#label-Usage">Usage</a>
|
55
|
+
<li><a href="#label-Contribute">Contribute</a>
|
56
|
+
<li><a href="#label-Authors">Authors</a>
|
57
|
+
<li><a href="#label-License">License</a>
|
58
|
+
</ul>
|
59
|
+
</nav>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
|
46
63
|
<div id="project-metadata">
|
47
64
|
<nav id="fileindex-section" class="section project-section">
|
48
65
|
<h3 class="section-header">Pages</h3>
|
@@ -67,6 +84,8 @@
|
|
67
84
|
|
68
85
|
<li><a href="./Kernel.html">Kernel</a>
|
69
86
|
|
87
|
+
<li><a href="./Module.html">Module</a>
|
88
|
+
|
70
89
|
<li><a href="./Object.html">Object</a>
|
71
90
|
|
72
91
|
<li><a href="./String.html">String</a>
|
@@ -79,7 +98,7 @@
|
|
79
98
|
|
80
99
|
<div id="documentation" class="description">
|
81
100
|
|
82
|
-
<h1 id="label-Shenanigans">Shenanigans
|
101
|
+
<h1 id="label-Shenanigans">Shenanigans<span><a href="#label-Shenanigans">¶</a> <a href="#documentation">↑</a></span></h1>
|
83
102
|
|
84
103
|
<p><strong>shenanigan</strong> (plural shenanigans):</p>
|
85
104
|
<ol><li>
|
@@ -99,7 +118,7 @@ but in reality, it is simply a complaint.</p>
|
|
99
118
|
<p>Source: <a
|
100
119
|
href="http://en.wiktionary.org/wiki/shenanigan#English">Wiktionary</a></p>
|
101
120
|
|
102
|
-
<h2 id="label-Introduction">Introduction
|
121
|
+
<h2 id="label-Introduction">Introduction<span><a href="#label-Introduction">¶</a> <a href="#documentation">↑</a></span></h2>
|
103
122
|
|
104
123
|
<p>Ruby Facets is the premiere collection of general purpose method extensions
|
105
124
|
and standard additions for the Ruby programming language. This is not Ruby
|
@@ -108,7 +127,7 @@ because I found them interesting and/or useful. Some of them I actually
|
|
108
127
|
also contributed to Facets, although sometimes they have different names or
|
109
128
|
slightly different implementations.</p>
|
110
129
|
|
111
|
-
<h2 id="label-Installation">Installation
|
130
|
+
<h2 id="label-Installation">Installation<span><a href="#label-Installation">¶</a> <a href="#documentation">↑</a></span></h2>
|
112
131
|
|
113
132
|
<p>Shenanigans can be installed via <a
|
114
133
|
href="http://rubygems.org/">RubyGems</a>.</p>
|
@@ -118,35 +137,35 @@ href="http://rubygems.org/">RubyGems</a>.</p>
|
|
118
137
|
<p>I only works on 1.9.3 and I generally only test it with the most current
|
119
138
|
Ruby release.</p>
|
120
139
|
|
121
|
-
<h2 id="label-Usage">Usage
|
140
|
+
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#documentation">↑</a></span></h2>
|
122
141
|
|
123
142
|
<p>If you really want the whole shebang, you can get it this way:</p>
|
124
143
|
|
125
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string"
|
144
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'shenanigans'</span>
|
126
145
|
</pre>
|
127
146
|
|
128
147
|
<p>Requiring a single method works as follows:</p>
|
129
148
|
|
130
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string"
|
149
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'shenanigans/<class|module>/<method>'</span>
|
131
150
|
</pre>
|
132
151
|
|
133
152
|
<p>Requiring all the extensions of a class or module also works:</p>
|
134
153
|
|
135
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string"
|
154
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'shenanigans/kernel'</span>
|
136
155
|
</pre>
|
137
156
|
|
138
|
-
<h2 id="label-Contribute">Contribute
|
157
|
+
<h2 id="label-Contribute">Contribute<span><a href="#label-Contribute">¶</a> <a href="#documentation">↑</a></span></h2>
|
139
158
|
|
140
159
|
<p>If you have something you want to contribute to Shenanigans, you shoud
|
141
160
|
reconsider and add it to Facets instead. This is a library for my own wonky
|
142
|
-
ideas and I don
|
161
|
+
ideas and I don't think it will ever see any real usage.</p>
|
143
162
|
|
144
|
-
<h2 id="label-Authors">Authors
|
163
|
+
<h2 id="label-Authors">Authors<span><a href="#label-Authors">¶</a> <a href="#documentation">↑</a></span></h2>
|
145
164
|
|
146
165
|
<p>This project was created by Michael Kohl. He can be reached via email at
|
147
166
|
citizen428 at gmail.com.</p>
|
148
167
|
|
149
|
-
<h2 id="label-License">License
|
168
|
+
<h2 id="label-License">License<span><a href="#label-License">¶</a> <a href="#documentation">↑</a></span></h2>
|
150
169
|
|
151
170
|
<p>Copyright © 2012 Michael Kohl</p>
|
152
171
|
|
@@ -174,7 +193,7 @@ DEALINGS IN THE SOFTWARE.</p>
|
|
174
193
|
|
175
194
|
<footer id="validator-badges">
|
176
195
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
177
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a>
|
196
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
|
178
197
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
179
198
|
</footer>
|
180
199
|
|
data/doc/String.html
CHANGED
@@ -43,6 +43,8 @@
|
|
43
43
|
</nav>
|
44
44
|
|
45
45
|
|
46
|
+
|
47
|
+
|
46
48
|
<div id="file-metadata">
|
47
49
|
<nav id="file-list-section" class="section">
|
48
50
|
<h3 class="section-header">Defined In</h3>
|
@@ -64,13 +66,14 @@
|
|
64
66
|
</nav>
|
65
67
|
|
66
68
|
|
69
|
+
|
67
70
|
<!-- Method Quickref -->
|
68
71
|
<nav id="method-list-section" class="section">
|
69
72
|
<h3 class="section-header">Methods</h3>
|
70
73
|
|
71
74
|
<ul class="link-list">
|
72
75
|
|
73
|
-
<li><a href="#method-i-in_groups_of">#in_groups_of</a>
|
76
|
+
<li ><a href="#method-i-in_groups_of">#in_groups_of</a>
|
74
77
|
|
75
78
|
</ul>
|
76
79
|
</nav>
|
@@ -101,6 +104,8 @@
|
|
101
104
|
|
102
105
|
<li><a href="./Kernel.html">Kernel</a>
|
103
106
|
|
107
|
+
<li><a href="./Module.html">Module</a>
|
108
|
+
|
104
109
|
<li><a href="./Object.html">Object</a>
|
105
110
|
|
106
111
|
<li><a href="./String.html">String</a>
|
@@ -141,7 +146,9 @@
|
|
141
146
|
<div class="method-heading">
|
142
147
|
<span class="method-name">in_groups_of</span><span
|
143
148
|
class="method-args">(size)</span>
|
149
|
+
|
144
150
|
<span class="method-click-advice">click to toggle source</span>
|
151
|
+
|
145
152
|
</div>
|
146
153
|
|
147
154
|
|
@@ -151,20 +158,21 @@
|
|
151
158
|
characters.</p>
|
152
159
|
|
153
160
|
<pre class="ruby"><span class="ruby-string">"aabbcc"</span>.<span class="ruby-identifier">in_groups_of</span>(<span class="ruby-value">2</span>)
|
154
|
-
<span class="ruby-comment">#=> [
|
161
|
+
<span class="ruby-comment">#=> ['aa', 'bb', 'cc']</span>
|
155
162
|
<span class="ruby-string">""</span>.<span class="ruby-identifier">in_groups_of</span>(<span class="ruby-value">2</span>)
|
156
163
|
<span class="ruby-comment">#=> []</span>
|
157
164
|
<span class="ruby-string">""</span>.<span class="ruby-identifier">in_groups_of</span>(<span class="ruby-value">0</span>)
|
158
165
|
<span class="ruby-comment">#=> ArgumentError</span>
|
159
166
|
</pre>
|
160
167
|
|
168
|
+
|
161
169
|
|
162
170
|
|
163
171
|
<div class="method-source-code" id="in_groups_of-source">
|
164
172
|
<pre><span class="ruby-comment"># File lib/shenanigans/string/in_groups_of.rb, line 10</span>
|
165
173
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">in_groups_of</span>(<span class="ruby-identifier">size</span>)
|
166
174
|
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">"Size of group must be >= 1"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator"><</span> <span class="ruby-value">1</span>
|
167
|
-
<span class="ruby-identifier">scan</span>(<span class="ruby-node"
|
175
|
+
<span class="ruby-identifier">scan</span>(<span class="ruby-node">/.{1,#{size}}/</span>)
|
168
176
|
<span class="ruby-keyword">end</span></pre>
|
169
177
|
</div><!-- in_groups_of-source -->
|
170
178
|
|
@@ -185,7 +193,7 @@ characters.</p>
|
|
185
193
|
|
186
194
|
<footer id="validator-badges">
|
187
195
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
188
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a>
|
196
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
|
189
197
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
190
198
|
</footer>
|
191
199
|
|