mack_ruby_core_extensions 0.1.8 → 0.1.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.
Files changed (38) hide show
  1. data/lib/extensions/hash.rb +6 -5
  2. data/test/extensions/hash_test.rb +5 -14
  3. metadata +3 -38
  4. data/doc/classes/Array.html +0 -465
  5. data/doc/classes/Class.html +0 -233
  6. data/doc/classes/Float.html +0 -148
  7. data/doc/classes/Hash.html +0 -232
  8. data/doc/classes/Kernel.html +0 -184
  9. data/doc/classes/Mack/Utils/Inflector.html +0 -422
  10. data/doc/classes/Math.html +0 -188
  11. data/doc/classes/MethodNotImplemented.html +0 -155
  12. data/doc/classes/Module.html +0 -203
  13. data/doc/classes/NilClass.html +0 -151
  14. data/doc/classes/Object.html +0 -448
  15. data/doc/classes/String.html +0 -977
  16. data/doc/classes/Symbol.html +0 -148
  17. data/doc/created.rid +0 -1
  18. data/doc/files/README.html +0 -151
  19. data/doc/files/lib/extensions/array_rb.html +0 -101
  20. data/doc/files/lib/extensions/class_rb.html +0 -101
  21. data/doc/files/lib/extensions/float_rb.html +0 -101
  22. data/doc/files/lib/extensions/hash_rb.html +0 -108
  23. data/doc/files/lib/extensions/kernel_rb.html +0 -109
  24. data/doc/files/lib/extensions/math_rb.html +0 -101
  25. data/doc/files/lib/extensions/method_not_implemented_rb.html +0 -108
  26. data/doc/files/lib/extensions/module_rb.html +0 -101
  27. data/doc/files/lib/extensions/nil_rb.html +0 -101
  28. data/doc/files/lib/extensions/object_rb.html +0 -101
  29. data/doc/files/lib/extensions/string_rb.html +0 -108
  30. data/doc/files/lib/extensions/symbol_rb.html +0 -101
  31. data/doc/files/lib/mack_ruby_core_extensions_rb.html +0 -101
  32. data/doc/files/lib/utils/inflections_rb.html +0 -101
  33. data/doc/files/lib/utils/inflector_rb.html +0 -108
  34. data/doc/fr_class_index.html +0 -39
  35. data/doc/fr_file_index.html +0 -42
  36. data/doc/fr_method_index.html +0 -96
  37. data/doc/index.html +0 -24
  38. data/doc/rdoc-style.css +0 -208
@@ -2,11 +2,12 @@ require 'uri'
2
2
  class Hash
3
3
 
4
4
  def join(pair_string, join_string)
5
- a = []
6
- self.each_pair do |k, v|
7
- a << sprintf(pair_string, k, v)
5
+ output = []
6
+ sorted = self.sort {|a,b| a[0].to_s <=> b[0].to_s}
7
+ sorted.each do |ar|
8
+ output << sprintf(pair_string, ar[0], ar[1])
8
9
  end
9
- a.join(join_string)
10
+ output.join(join_string)
10
11
  end
11
12
 
12
13
  # Deletes the key(s) passed in from the hash.
@@ -42,7 +43,7 @@ class Hash
42
43
  end
43
44
 
44
45
  params.chop! # trailing &
45
- params
46
+ params.split("&").sort.join("&")
46
47
  end
47
48
 
48
49
  end
@@ -20,26 +20,17 @@ class HashTest < Test::Unit::TestCase
20
20
 
21
21
  def test_join
22
22
  h = {:rel => "nofollow", :alt => "pickles"}
23
- # assert_equal "rel=\"nofollow\" alt=\"pickles\"", h.join("%s=\"%s\"", " ")
24
- assert ("rel=\"nofollow\" alt=\"pickles\"" == h.join("%s=\"%s\"", " ") || "alt=\"pickles\" rel=\"nofollow\"" == h.join("%s=\"%s\"", " "))
23
+ assert_equal "alt=\"pickles\" rel=\"nofollow\"", h.join("%s=\"%s\"", " ")
25
24
  end
26
25
 
27
26
  def test_to_params
28
27
  h = {:a => "aaa", :b => "bbb", :c => "ccc"}
29
- assert(h.to_params == "a=aaa&b=bbb&c=ccc" ||
30
- h.to_params == "b=bbb&c=ccc&a=aaa" ||
31
- h.to_params == "b=bbb&c=ccc&a=aaa" ||
32
- h.to_params == "b=bbb&a=aaa&c=ccc")
28
+ assert_equal "a=aaa&b=bbb&c=ccc", h.to_params
33
29
 
34
30
  h = {:a => "aaa", :b => "bbb", :c => "Hello World!"}
35
- puts h.to_params
36
- assert(h.to_params == "b=bbb&c=Hello%20World!&a=aaa" ||
37
- h.to_params == "b=bbb&a=aaa&c=Hello%20World!" ||
38
- h.to_params == "b=bbb&a=aaa&c=Hello+World%21" ||
39
- h.to_params == "b=bbb&c=Hello+World%21&a=aaa")
40
-
41
- assert(h.to_params(false) == "b=bbb&c=Hello World!&a=aaa" ||
42
- h.to_params(false) == "b=bbb&a=aaa&c=Hello World!")
31
+ assert_equal "a=aaa&b=bbb&c=Hello+World%21", h.to_params
32
+
33
+ assert_equal "a=aaa&b=bbb&c=Hello World!", h.to_params(false)
43
34
 
44
35
  h = {:a => "aaa", :b => {:one => "won", :two => "too"}}
45
36
  assert_equal "a=aaa&b[one]=won&b[two]=too", h.to_params
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mack_ruby_core_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-27 00:00:00 -04:00
12
+ date: 2008-04-28 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -38,41 +38,6 @@ files:
38
38
  - lib/utils/inflections.rb
39
39
  - lib/utils/inflector.rb
40
40
  - README
41
- - doc/classes/Array.html
42
- - doc/classes/Class.html
43
- - doc/classes/Float.html
44
- - doc/classes/Hash.html
45
- - doc/classes/Kernel.html
46
- - doc/classes/Mack/Utils/Inflector.html
47
- - doc/classes/Math.html
48
- - doc/classes/MethodNotImplemented.html
49
- - doc/classes/Module.html
50
- - doc/classes/NilClass.html
51
- - doc/classes/Object.html
52
- - doc/classes/String.html
53
- - doc/classes/Symbol.html
54
- - doc/created.rid
55
- - doc/files/lib/extensions/array_rb.html
56
- - doc/files/lib/extensions/class_rb.html
57
- - doc/files/lib/extensions/float_rb.html
58
- - doc/files/lib/extensions/hash_rb.html
59
- - doc/files/lib/extensions/kernel_rb.html
60
- - doc/files/lib/extensions/math_rb.html
61
- - doc/files/lib/extensions/method_not_implemented_rb.html
62
- - doc/files/lib/extensions/module_rb.html
63
- - doc/files/lib/extensions/nil_rb.html
64
- - doc/files/lib/extensions/object_rb.html
65
- - doc/files/lib/extensions/string_rb.html
66
- - doc/files/lib/extensions/symbol_rb.html
67
- - doc/files/lib/mack_ruby_core_extensions_rb.html
68
- - doc/files/lib/utils/inflections_rb.html
69
- - doc/files/lib/utils/inflector_rb.html
70
- - doc/files/README.html
71
- - doc/fr_class_index.html
72
- - doc/fr_file_index.html
73
- - doc/fr_method_index.html
74
- - doc/index.html
75
- - doc/rdoc-style.css
76
41
  has_rdoc: true
77
42
  homepage: http://www.mackframework.com
78
43
  post_install_message:
@@ -101,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
66
  requirements: []
102
67
 
103
68
  rubyforge_project: magrathea
104
- rubygems_version: 1.1.1
69
+ rubygems_version: 1.0.1
105
70
  signing_key:
106
71
  specification_version: 2
107
72
  summary: mack_ruby_core_extensions
@@ -1,465 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Array</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Array</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/extensions/array_rb.html">
59
- lib/extensions/array.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- <a href="Object.html">
69
- Object
70
- </a>
71
- </td>
72
- </tr>
73
- </table>
74
- </div>
75
- <!-- banner header -->
76
-
77
- <div id="bodyContent">
78
-
79
-
80
-
81
- <div id="contextContent">
82
-
83
-
84
-
85
- </div>
86
-
87
- <div id="method-list">
88
- <h3 class="section-bar">Methods</h3>
89
-
90
- <div class="name-list">
91
- <a href="#M000014">count</a>&nbsp;&nbsp;
92
- <a href="#M000006">delete_from_array</a>&nbsp;&nbsp;
93
- <a href="#M000007">delete_from_array!</a>&nbsp;&nbsp;
94
- <a href="#M000015">invert</a>&nbsp;&nbsp;
95
- <a href="#M000005">parse_splat_args</a>&nbsp;&nbsp;
96
- <a href="#M000010">pick_random</a>&nbsp;&nbsp;
97
- <a href="#M000011">random_each</a>&nbsp;&nbsp;
98
- <a href="#M000008">randomize</a>&nbsp;&nbsp;
99
- <a href="#M000009">randomize!</a>&nbsp;&nbsp;
100
- <a href="#M000012">subset?</a>&nbsp;&nbsp;
101
- <a href="#M000013">superset?</a>&nbsp;&nbsp;
102
- </div>
103
- </div>
104
-
105
- </div>
106
-
107
-
108
- <!-- if includes -->
109
-
110
- <div id="section">
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
- <!-- if method_list -->
120
- <div id="methods">
121
- <h3 class="section-bar">Public Instance methods</h3>
122
-
123
- <div id="method-M000014" class="method-detail">
124
- <a name="M000014"></a>
125
-
126
- <div class="method-heading">
127
- <a href="#M000014" class="method-signature">
128
- <span class="method-name">count</span><span class="method-args">()</span>
129
- </a>
130
- </div>
131
-
132
- <div class="method-description">
133
- <p>
134
- This will give you a <a href="Array.html#M000014">count</a>, as a <a
135
- href="Hash.html">Hash</a>, of all the values in the <a
136
- href="Array.html">Array</a>. %w{spam spam eggs ham eggs spam}.<a
137
- href="Array.html#M000014">count</a> # =&gt; {&quot;eggs&quot; =&gt; 2,
138
- &quot;ham&quot; =&gt; 1, &quot;spam&quot; =&gt; 3}
139
- </p>
140
- <p><a class="source-toggle" href="#"
141
- onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
142
- <div class="method-source-code" id="M000014-source">
143
- <pre>
144
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 87</span>
145
- 87: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">count</span>
146
- 88: <span class="ruby-identifier">k</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>)
147
- 89: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span>[<span class="ruby-identifier">x</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>}
148
- 90: <span class="ruby-identifier">k</span>
149
- 91: <span class="ruby-keyword kw">end</span>
150
- </pre>
151
- </div>
152
- </div>
153
- </div>
154
-
155
- <div id="method-M000006" class="method-detail">
156
- <a name="M000006"></a>
157
-
158
- <div class="method-heading">
159
- <a href="#M000006" class="method-signature">
160
- <span class="method-name">delete_from_array</span><span class="method-args">(args)</span>
161
- </a>
162
- </div>
163
-
164
- <div class="method-description">
165
- <p>
166
- This allows you to delete an array of values from another array.
167
- [1,2,3,4,5].<a href="Array.html#M000006">delete_from_array</a>([2,3,5]) #
168
- =&gt; [1,4]
169
- </p>
170
- <p><a class="source-toggle" href="#"
171
- onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
172
- <div class="method-source-code" id="M000006-source">
173
- <pre>
174
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 37</span>
175
- 37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_from_array</span>(<span class="ruby-identifier">args</span>)
176
- 38: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">collect</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span> <span class="ruby-keyword kw">unless</span> [<span class="ruby-identifier">args</span>].<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">x</span>)}.<span class="ruby-identifier">compact</span>
177
- 39: <span class="ruby-keyword kw">end</span>
178
- </pre>
179
- </div>
180
- </div>
181
- </div>
182
-
183
- <div id="method-M000007" class="method-detail">
184
- <a name="M000007"></a>
185
-
186
- <div class="method-heading">
187
- <a href="#M000007" class="method-signature">
188
- <span class="method-name">delete_from_array!</span><span class="method-args">(args)</span>
189
- </a>
190
- </div>
191
-
192
- <div class="method-description">
193
- <p>
194
- This calls the <a href="Array.html#M000006">delete_from_array</a> method,
195
- but will permantly replace the existing array.
196
- </p>
197
- <p><a class="source-toggle" href="#"
198
- onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
199
- <div class="method-source-code" id="M000007-source">
200
- <pre>
201
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 42</span>
202
- 42: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_from_array!</span>(<span class="ruby-identifier">args</span>)
203
- 43: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">delete_from_array</span>(<span class="ruby-identifier">args</span>))
204
- 44: <span class="ruby-keyword kw">end</span>
205
- </pre>
206
- </div>
207
- </div>
208
- </div>
209
-
210
- <div id="method-M000015" class="method-detail">
211
- <a name="M000015"></a>
212
-
213
- <div class="method-heading">
214
- <a href="#M000015" class="method-signature">
215
- <span class="method-name">invert</span><span class="method-args">()</span>
216
- </a>
217
- </div>
218
-
219
- <div class="method-description">
220
- <p>
221
- This will <a href="Array.html#M000015">invert</a> the index and the values
222
- and return a <a href="Hash.html">Hash</a> of the results. %w{red yellow
223
- orange}.<a href="Array.html#M000015">invert</a> # =&gt; {&quot;red&quot;
224
- =&gt; 0, &quot;orange&quot; =&gt; 2, &quot;yellow&quot; =&gt; 1}
225
- </p>
226
- <p><a class="source-toggle" href="#"
227
- onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
228
- <div class="method-source-code" id="M000015-source">
229
- <pre>
230
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 95</span>
231
- 95: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">invert</span>
232
- 96: <span class="ruby-identifier">h</span> = {}
233
- 97: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each_with_index</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">x</span>,<span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">x</span>] = <span class="ruby-identifier">i</span>}
234
- 98: <span class="ruby-identifier">h</span>
235
- 99: <span class="ruby-keyword kw">end</span>
236
- </pre>
237
- </div>
238
- </div>
239
- </div>
240
-
241
- <div id="method-M000005" class="method-detail">
242
- <a name="M000005"></a>
243
-
244
- <div class="method-heading">
245
- <a href="#M000005" class="method-signature">
246
- <span class="method-name">parse_splat_args</span><span class="method-args">()</span>
247
- </a>
248
- </div>
249
-
250
- <div class="method-description">
251
- <p>
252
- This method is useful when you have a method that looks like this: def
253
- foo(*args)
254
- </p>
255
- <pre>
256
- do something
257
- </pre>
258
- <p>
259
- end The problem is when you use the * like that everything that comes in is
260
- an array. Here are a few problems with this: foo([1,2,3]) When you pass an
261
- array into this type of method you get the following nested array:
262
- [[1,2,3]] The <a href="Array.html#M000005">parse_splat_args</a> method, if
263
- called, would do this: args.parse_splat_args # =&gt; [1,2,3] Now say you
264
- called this method like such: foo(1) args would be [1]
265
- args.parse_splat_args # =&gt; 1 Finally foo args.parse_splat_args # =&gt;
266
- nil
267
- </p>
268
- <p><a class="source-toggle" href="#"
269
- onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
270
- <div class="method-source-code" id="M000005-source">
271
- <pre>
272
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 21</span>
273
- 21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_splat_args</span>
274
- 22: <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">empty?</span>
275
- 23: <span class="ruby-identifier">args</span> = <span class="ruby-keyword kw">self</span><span class="ruby-comment cmt">#.flatten</span>
276
- 24: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span>
277
- 25: <span class="ruby-keyword kw">when</span> <span class="ruby-value">1</span>
278
- 26: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span> <span class="ruby-comment cmt"># if there was only one arg passed, return just that, without the array</span>
279
- 27: <span class="ruby-keyword kw">when</span> <span class="ruby-value">0</span>
280
- 28: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># if no args were passed return nil</span>
281
- 29: <span class="ruby-keyword kw">else</span>
282
- 30: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">args</span> <span class="ruby-comment cmt"># else return the array back, cause chances are that's what they passed you!</span>
283
- 31: <span class="ruby-keyword kw">end</span>
284
- 32: <span class="ruby-keyword kw">end</span>
285
- 33: <span class="ruby-keyword kw">end</span>
286
- </pre>
287
- </div>
288
- </div>
289
- </div>
290
-
291
- <div id="method-M000010" class="method-detail">
292
- <a name="M000010"></a>
293
-
294
- <div class="method-heading">
295
- <a href="#M000010" class="method-signature">
296
- <span class="method-name">pick_random</span><span class="method-args">()</span>
297
- </a>
298
- </div>
299
-
300
- <div class="method-description">
301
- <p>
302
- This will pick a random value from the array
303
- </p>
304
- <p><a class="source-toggle" href="#"
305
- onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
306
- <div class="method-source-code" id="M000010-source">
307
- <pre>
308
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 65</span>
309
- 65: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pick_random</span>
310
- 66: <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">rand</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span>)]
311
- 67: <span class="ruby-keyword kw">end</span>
312
- </pre>
313
- </div>
314
- </div>
315
- </div>
316
-
317
- <div id="method-M000011" class="method-detail">
318
- <a name="M000011"></a>
319
-
320
- <div class="method-heading">
321
- <a href="#M000011" class="method-signature">
322
- <span class="method-name">random_each</span><span class="method-args">() {|x| ...}</span>
323
- </a>
324
- </div>
325
-
326
- <div class="method-description">
327
- <p>
328
- This allows you to easily recurse of the array randomly.
329
- </p>
330
- <p><a class="source-toggle" href="#"
331
- onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
332
- <div class="method-source-code" id="M000011-source">
333
- <pre>
334
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 70</span>
335
- 70: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">random_each</span>
336
- 71: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">randomize</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">x</span>}
337
- 72: <span class="ruby-keyword kw">end</span>
338
- </pre>
339
- </div>
340
- </div>
341
- </div>
342
-
343
- <div id="method-M000008" class="method-detail">
344
- <a name="M000008"></a>
345
-
346
- <div class="method-heading">
347
- <a href="#M000008" class="method-signature">
348
- <span class="method-name">randomize</span><span class="method-args">() {|x, y| ...}</span>
349
- </a>
350
- </div>
351
-
352
- <div class="method-description">
353
- <p>
354
- This will return a new instance of the array sorted randomly.
355
- </p>
356
- <p><a class="source-toggle" href="#"
357
- onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
358
- <div class="method-source-code" id="M000008-source">
359
- <pre>
360
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 47</span>
361
- 47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">randomize</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
362
- 48: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
363
- 49: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">sort</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span>}
364
- 50: <span class="ruby-keyword kw">else</span>
365
- 51: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">sort_by</span> { <span class="ruby-identifier">rand</span> }
366
- 52: <span class="ruby-keyword kw">end</span>
367
- 53: <span class="ruby-keyword kw">end</span>
368
- </pre>
369
- </div>
370
- </div>
371
- </div>
372
-
373
- <div id="method-M000009" class="method-detail">
374
- <a name="M000009"></a>
375
-
376
- <div class="method-heading">
377
- <a href="#M000009" class="method-signature">
378
- <span class="method-name">randomize!</span><span class="method-args">(&amp;block)</span>
379
- </a>
380
- </div>
381
-
382
- <div class="method-description">
383
- <p>
384
- This calls the <a href="Array.html#M000008">randomize</a> method, but will
385
- permantly replace the existing array.
386
- </p>
387
- <p><a class="source-toggle" href="#"
388
- onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
389
- <div class="method-source-code" id="M000009-source">
390
- <pre>
391
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 56</span>
392
- 56: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">randomize!</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
393
- 57: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
394
- 58: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">randomize</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>))
395
- 59: <span class="ruby-keyword kw">else</span>
396
- 60: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">randomize</span>)
397
- 61: <span class="ruby-keyword kw">end</span>
398
- 62: <span class="ruby-keyword kw">end</span>
399
- </pre>
400
- </div>
401
- </div>
402
- </div>
403
-
404
- <div id="method-M000012" class="method-detail">
405
- <a name="M000012"></a>
406
-
407
- <div class="method-heading">
408
- <a href="#M000012" class="method-signature">
409
- <span class="method-name">subset?</span><span class="method-args">(other)</span>
410
- </a>
411
- </div>
412
-
413
- <div class="method-description">
414
- <p><a class="source-toggle" href="#"
415
- onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
416
- <div class="method-source-code" id="M000012-source">
417
- <pre>
418
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 74</span>
419
- 74: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">subset?</span>(<span class="ruby-identifier">other</span>)
420
- 75: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span>
421
- 76: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">x</span>)
422
- 77: <span class="ruby-keyword kw">end</span>
423
- 78: <span class="ruby-keyword kw">true</span>
424
- 79: <span class="ruby-keyword kw">end</span>
425
- </pre>
426
- </div>
427
- </div>
428
- </div>
429
-
430
- <div id="method-M000013" class="method-detail">
431
- <a name="M000013"></a>
432
-
433
- <div class="method-heading">
434
- <a href="#M000013" class="method-signature">
435
- <span class="method-name">superset?</span><span class="method-args">(other)</span>
436
- </a>
437
- </div>
438
-
439
- <div class="method-description">
440
- <p><a class="source-toggle" href="#"
441
- onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
442
- <div class="method-source-code" id="M000013-source">
443
- <pre>
444
- <span class="ruby-comment cmt"># File lib/extensions/array.rb, line 81</span>
445
- 81: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">superset?</span>(<span class="ruby-identifier">other</span>)
446
- 82: <span class="ruby-identifier">other</span>.<span class="ruby-identifier">subset?</span>(<span class="ruby-keyword kw">self</span>)
447
- 83: <span class="ruby-keyword kw">end</span>
448
- </pre>
449
- </div>
450
- </div>
451
- </div>
452
-
453
-
454
- </div>
455
-
456
-
457
- </div>
458
-
459
-
460
- <div id="validator-badges">
461
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
462
- </div>
463
-
464
- </body>
465
- </html>