shenanigans 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -101,6 +101,8 @@
101
101
 
102
102
  <li><a href="./Array.html">Array</a>
103
103
 
104
+ <li><a href="./Fixnum.html">Fixnum</a>
105
+
104
106
  <li><a href="./Hash.html">Hash</a>
105
107
 
106
108
  <li><a href="./Kernel.html">Kernel</a>
@@ -160,7 +162,7 @@
160
162
  <div class="method-source-code" id="5E-source">
161
163
  <pre><span class="ruby-comment"># File lib/shenanigans/array/caret.rb, line 5</span>
162
164
  <span class="ruby-keyword">def</span> <span class="ruby-operator">^</span>(<span class="ruby-identifier">other</span>)
163
- (<span class="ruby-keyword">self</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">other</span>) <span class="ruby-operator">-</span> (<span class="ruby-keyword">self</span> &amp; <span class="ruby-identifier">other</span>)
165
+ (<span class="ruby-keyword">self</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">other</span>) <span class="ruby-operator">|</span> (<span class="ruby-identifier">other</span> <span class="ruby-operator">-</span> <span class="ruby-keyword">self</span>)
164
166
  <span class="ruby-keyword">end</span></pre>
165
167
  </div><!-- 5E-source -->
166
168
 
@@ -0,0 +1,189 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6
+
7
+ <title>class Fixnum - 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
+ <div id="file-metadata">
47
+ <nav id="file-list-section" class="section">
48
+ <h3 class="section-header">Defined In</h3>
49
+ <ul>
50
+ <li>lib/shenanigans/fixnum/string_length.rb
51
+ </ul>
52
+ </nav>
53
+
54
+
55
+ </div>
56
+
57
+ <div id="class-metadata">
58
+
59
+ <nav id="parent-class-section" class="section">
60
+ <h3 class="section-header">Parent</h3>
61
+
62
+ <p class="link"><a href="Object.html">Object</a>
63
+
64
+ </nav>
65
+
66
+
67
+ <!-- Method Quickref -->
68
+ <nav id="method-list-section" class="section">
69
+ <h3 class="section-header">Methods</h3>
70
+
71
+ <ul class="link-list">
72
+
73
+ <li><a href="#method-i-string_length">#string_length</a>
74
+
75
+ </ul>
76
+ </nav>
77
+
78
+ </div>
79
+
80
+ <div id="project-metadata">
81
+ <nav id="fileindex-section" class="section project-section">
82
+ <h3 class="section-header">Pages</h3>
83
+
84
+ <ul>
85
+
86
+ <li class="file"><a href="./README_rdoc.html">README</a>
87
+
88
+ </ul>
89
+ </nav>
90
+
91
+ <nav id="classindex-section" class="section project-section">
92
+ <h3 class="section-header">Class and Module Index</h3>
93
+
94
+ <ul class="link-list">
95
+
96
+ <li><a href="./Array.html">Array</a>
97
+
98
+ <li><a href="./Fixnum.html">Fixnum</a>
99
+
100
+ <li><a href="./Hash.html">Hash</a>
101
+
102
+ <li><a href="./Kernel.html">Kernel</a>
103
+
104
+ <li><a href="./Object.html">Object</a>
105
+
106
+ </ul>
107
+ </nav>
108
+
109
+ </div>
110
+ </nav>
111
+
112
+ <div id="documentation">
113
+ <h1 class="class">class Fixnum</h1>
114
+
115
+ <div id="description" class="description">
116
+
117
+ </div><!-- description -->
118
+
119
+
120
+
121
+
122
+ <section id="5Buntitled-5D" class="documentation-section">
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+ <!-- Methods -->
132
+
133
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
134
+ <h3 class="section-header">Public Instance Methods</h3>
135
+
136
+
137
+ <div id="method-i-string_length" class="method-detail ">
138
+
139
+ <div class="method-heading">
140
+ <span class="method-name">string_length</span><span
141
+ class="method-args">()</span>
142
+ <span class="method-click-advice">click to toggle source</span>
143
+ </div>
144
+
145
+
146
+ <div class="method-description">
147
+
148
+ <p>Returns the lenth of the number’s string representation</p>
149
+
150
+ <pre class="ruby"><span class="ruby-value">0</span>.<span class="ruby-identifier">string_length</span>
151
+ <span class="ruby-comment">#=&gt; 1</span>
152
+ <span class="ruby-value">123</span>.<span class="ruby-identifier">string_length</span>
153
+ <span class="ruby-comment">#=&gt; 3</span>
154
+ <span class="ruby-value">-1</span>.<span class="ruby-identifier">string_length</span>
155
+ <span class="ruby-comment">#=&gt; 2</span>
156
+ </pre>
157
+
158
+
159
+
160
+ <div class="method-source-code" id="string_length-source">
161
+ <pre><span class="ruby-comment"># File lib/shenanigans/fixnum/string_length.rb, line 9</span>
162
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">string_length</span>
163
+ <span class="ruby-keyword">return</span> <span class="ruby-value">1</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">zero?</span>
164
+ <span class="ruby-identifier">len</span> = <span class="ruby-constant">Math</span>.<span class="ruby-identifier">log10</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">abs</span>).<span class="ruby-identifier">floor</span>.<span class="ruby-identifier">next</span>
165
+ <span class="ruby-keyword">self</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">len</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">len</span>.<span class="ruby-identifier">next</span>
166
+ <span class="ruby-keyword">end</span></pre>
167
+ </div><!-- string_length-source -->
168
+
169
+ </div>
170
+
171
+
172
+
173
+
174
+ </div><!-- string_length-method -->
175
+
176
+
177
+ </section><!-- public-instance-method-details -->
178
+
179
+ </section><!-- 5Buntitled-5D -->
180
+
181
+ </div><!-- documentation -->
182
+
183
+
184
+ <footer id="validator-badges">
185
+ <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
186
+ <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
187
+ <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
188
+ </footer>
189
+
@@ -98,6 +98,8 @@
98
98
 
99
99
  <li><a href="./Array.html">Array</a>
100
100
 
101
+ <li><a href="./Fixnum.html">Fixnum</a>
102
+
101
103
  <li><a href="./Hash.html">Hash</a>
102
104
 
103
105
  <li><a href="./Kernel.html">Kernel</a>
@@ -95,6 +95,8 @@
95
95
 
96
96
  <li><a href="./Array.html">Array</a>
97
97
 
98
+ <li><a href="./Fixnum.html">Fixnum</a>
99
+
98
100
  <li><a href="./Hash.html">Hash</a>
99
101
 
100
102
  <li><a href="./Kernel.html">Kernel</a>
@@ -48,7 +48,7 @@
48
48
  <h3 class="section-header">Defined In</h3>
49
49
  <ul>
50
50
  <li>lib/shenanigans/object/display.rb
51
- <li>lib/shenanigans/object/identity.rb
51
+ <li>lib/shenanigans/object/it.rb
52
52
  </ul>
53
53
  </nav>
54
54
 
@@ -75,7 +75,7 @@
75
75
 
76
76
  <li><a href="#method-i-display">#display</a>
77
77
 
78
- <li><a href="#method-i-identity">#identity</a>
78
+ <li><a href="#method-i-it">#it</a>
79
79
 
80
80
  </ul>
81
81
  </nav>
@@ -100,6 +100,8 @@
100
100
 
101
101
  <li><a href="./Array.html">Array</a>
102
102
 
103
+ <li><a href="./Fixnum.html">Fixnum</a>
104
+
103
105
  <li><a href="./Hash.html">Hash</a>
104
106
 
105
107
  <li><a href="./Kernel.html">Kernel</a>
@@ -209,10 +211,10 @@ otherwise.</p>
209
211
  </div><!-- display-method -->
210
212
 
211
213
 
212
- <div id="method-i-identity" class="method-detail ">
214
+ <div id="method-i-it" class="method-detail ">
213
215
 
214
216
  <div class="method-heading">
215
- <span class="method-name">identity</span><span
217
+ <span class="method-name">it</span><span
216
218
  class="method-args">()</span>
217
219
  <span class="method-click-advice">click to toggle source</span>
218
220
  </div>
@@ -222,25 +224,25 @@ otherwise.</p>
222
224
 
223
225
  <p>An identity method that provides access to an object’s <code>self</code>.</p>
224
226
 
225
- <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>(&amp;:<span class="ruby-identifier">identity</span>)
227
+ <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>(&amp;:<span class="ruby-identifier">it</span>)
226
228
  <span class="ruby-comment">#=&gt; {1=&gt;[1, 1], 2=&gt;[2, 2, 2], 3=&gt;[3, 3], 4=&gt;[4], 5=&gt;[5]}</span>
227
229
  </pre>
228
230
 
229
231
 
230
232
 
231
- <div class="method-source-code" id="identity-source">
232
- <pre><span class="ruby-comment"># File lib/shenanigans/object/identity.rb, line 6</span>
233
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">identity</span>
233
+ <div class="method-source-code" id="it-source">
234
+ <pre><span class="ruby-comment"># File lib/shenanigans/object/it.rb, line 6</span>
235
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">it</span>
234
236
  <span class="ruby-keyword">self</span>
235
237
  <span class="ruby-keyword">end</span></pre>
236
- </div><!-- identity-source -->
238
+ </div><!-- it-source -->
237
239
 
238
240
  </div>
239
241
 
240
242
 
241
243
 
242
244
 
243
- </div><!-- identity-method -->
245
+ </div><!-- it-method -->
244
246
 
245
247
 
246
248
  </section><!-- public-instance-method-details -->
@@ -61,6 +61,8 @@
61
61
 
62
62
  <li><a href="./Array.html">Array</a>
63
63
 
64
+ <li><a href="./Fixnum.html">Fixnum</a>
65
+
64
66
  <li><a href="./Hash.html">Hash</a>
65
67
 
66
68
  <li><a href="./Kernel.html">Kernel</a>
@@ -1,9 +1,11 @@
1
- Thu, 28 Jun 2012 09:01:37 +0200
1
+ Sun, 15 Jul 2012 00:00:08 +0200
2
2
  README.rdoc Thu, 17 May 2012 11:45:08 +0200
3
- lib/shenanigans/array/caret.rb Thu, 28 Jun 2012 09:01:33 +0200
3
+ lib/shenanigans/array/caret.rb Thu, 28 Jun 2012 09:15:50 +0200
4
4
  lib/shenanigans/array/random_subarray.rb Thu, 17 May 2012 00:03:23 +0200
5
5
  lib/shenanigans/array/zip_with.rb Tue, 19 Jun 2012 21:23:27 +0200
6
6
  lib/shenanigans/array.rb Thu, 28 Jun 2012 09:00:29 +0200
7
+ lib/shenanigans/fixnum/string_length.rb Sun, 15 Jul 2012 00:00:03 +0200
8
+ lib/shenanigans/fixnum.rb Sat, 14 Jul 2012 23:49:59 +0200
7
9
  lib/shenanigans/hash/has_shape_pred.rb Tue, 19 Jun 2012 21:25:03 +0200
8
10
  lib/shenanigans/hash/to_ostruct.rb Tue, 26 Jun 2012 21:24:42 +0200
9
11
  lib/shenanigans/hash.rb Thu, 21 Jun 2012 19:13:44 +0200
@@ -12,6 +14,6 @@ lib/shenanigans/kernel/prompt.rb Thu, 17 May 2012 00:10:42 +0200
12
14
  lib/shenanigans/kernel/with.rb Thu, 17 May 2012 00:00:08 +0200
13
15
  lib/shenanigans/kernel.rb Wed, 16 May 2012 20:49:22 +0200
14
16
  lib/shenanigans/object/display.rb Fri, 25 May 2012 17:29:45 +0200
15
- lib/shenanigans/object/identity.rb Wed, 16 May 2012 23:51:07 +0200
16
- lib/shenanigans/object.rb Fri, 25 May 2012 15:31:08 +0200
17
- lib/shenanigans.rb Tue, 19 Jun 2012 21:04:30 +0200
17
+ lib/shenanigans/object/it.rb Thu, 28 Jun 2012 09:07:56 +0200
18
+ lib/shenanigans/object.rb Thu, 28 Jun 2012 09:10:12 +0200
19
+ lib/shenanigans.rb Sat, 14 Jul 2012 23:53:13 +0200
@@ -61,6 +61,8 @@
61
61
 
62
62
  <li><a href="./Array.html">Array</a>
63
63
 
64
+ <li><a href="./Fixnum.html">Fixnum</a>
65
+
64
66
  <li><a href="./Hash.html">Hash</a>
65
67
 
66
68
  <li><a href="./Kernel.html">Kernel</a>
@@ -1 +1 @@
1
- var search_data = {"index":{"searchIndex":["array","hash","kernel","object","^()","d()","display()","fn()","has_shape?()","identity()","prompt()","random_subarray()","to_ostruct()","with()","zip_with()","readme"],"longSearchIndex":["array","hash","kernel","object","array#^()","object#d()","object#display()","kernel#fn()","hash#has_shape?()","object#identity()","kernel#prompt()","array#random_subarray()","hash#to_ostruct()","kernel#with()","array#zip_with()",""],"info":[["Array","","Array.html","",""],["Hash","","Hash.html","",""],["Kernel","","Kernel.html","",""],["Object","","Object.html","",""],["^","Array","Array.html#method-i-5E","(other)","<p>Returns an array containing elements exclusive between two arrays.\n\n<pre class=\"ruby\">[<span class=\"ruby-value\">1</span>, <span class=\"ruby-value\">2</span>, <span class=\"ruby-value\">3</span>] <span class=\"ruby-operator\">^</span> [<span class=\"ruby-value\">1</span>, <span class=\"ruby-value\">2</span>, <span class=\"ruby-value\">4</span>]\n<span class=\"ruby-comment\">#=&gt; [3, 4]</span>\n</pre>\n"],["d","Object","Object.html#method-i-d","(new_line = true)",""],["display","Object","Object.html#method-i-display","(new_line = true)","<p>Outputs the object and also returns it. Will use <code>puts</code> if\n<code>new_line</code> is <code>true</code> and <code>print</code>\notherwise.\n\n<pre>&quot;foo&quot;.display ...</pre>\n"],["fn","Kernel","Kernel.html#method-i-fn","(*funs)","<p>Composes a list of functions. Functions can be specified as symbols or\nlambdas.\n\n<pre>[&quot;foo bar&quot;, &quot;baz qux&quot;].map ...</pre>\n"],["has_shape?","Hash","Hash.html#method-i-has_shape-3F","(shape)","<p>Checks if a hash has a certain structure.\n\n<pre>h = { k1: 1, k2: &quot;1&quot; }\nh.has_shape?(k1: Fixnum, k2: String) ...</pre>\n"],["identity","Object","Object.html#method-i-identity","()","<p>An identity method that provides access to an object’s <code>self</code>.\n\n<pre>[1,2,3,4,5,1,2,2,3].group_by(&amp;:identity) ...</pre>\n"],["prompt","Kernel","Kernel.html#method-i-prompt","(text='', conversion=nil)","<p>Displays a prompt and returns chomped input. Modelled after the Python\nmethod <code>raw_input</code>, but also can …\n"],["random_subarray","Array","Array.html#method-i-random_subarray","(n=1)","<p>Generates random subarrays. Uses random numbers and bit-fiddling to assure\nperformant uniform distributions …\n"],["to_ostruct","Hash","Hash.html#method-i-to_ostruct","()","<p>Recursively converts a <code>Hash</code> and all nested <code>Hash</code>es\nto <code>OpenStruct</code>s. Especially useful for parsing YAML …\n"],["with","Kernel","Kernel.html#method-i-with","(o, &blk)","<p>A Pascal/ActionScript like <code>with</code> method. Yields its argument to\nthe provided block and then returns it. …\n"],["zip_with","Array","Array.html#method-i-zip_with","(other, op=nil)","<p>Zip <code>self</code> with <code>other</code>, combining the elements with\nthe provided block or symbol. The resulting array will …\n"],["README","","README_rdoc.html","","<p>Shenanigans\n<p><strong>shenanigan</strong> (plural shenanigans):\n<p>Trickery, games; skulduggery. To “call”, “claim” …\n"]]}}
1
+ var search_data = {"index":{"searchIndex":["array","fixnum","hash","kernel","object","^()","d()","display()","fn()","has_shape?()","it()","prompt()","random_subarray()","string_length()","to_ostruct()","with()","zip_with()","readme"],"longSearchIndex":["array","fixnum","hash","kernel","object","array#^()","object#d()","object#display()","kernel#fn()","hash#has_shape?()","object#it()","kernel#prompt()","array#random_subarray()","fixnum#string_length()","hash#to_ostruct()","kernel#with()","array#zip_with()",""],"info":[["Array","","Array.html","",""],["Fixnum","","Fixnum.html","",""],["Hash","","Hash.html","",""],["Kernel","","Kernel.html","",""],["Object","","Object.html","",""],["^","Array","Array.html#method-i-5E","(other)","<p>Returns an array containing elements exclusive between two arrays.\n\n<pre class=\"ruby\">[<span class=\"ruby-value\">1</span>, <span class=\"ruby-value\">2</span>, <span class=\"ruby-value\">3</span>] <span class=\"ruby-operator\">^</span> [<span class=\"ruby-value\">1</span>, <span class=\"ruby-value\">2</span>, <span class=\"ruby-value\">4</span>]\n<span class=\"ruby-comment\">#=&gt; [3, 4]</span>\n</pre>\n"],["d","Object","Object.html#method-i-d","(new_line = true)",""],["display","Object","Object.html#method-i-display","(new_line = true)","<p>Outputs the object and also returns it. Will use <code>puts</code> if\n<code>new_line</code> is <code>true</code> and <code>print</code>\notherwise.\n\n<pre>&quot;foo&quot;.display ...</pre>\n"],["fn","Kernel","Kernel.html#method-i-fn","(*funs)","<p>Composes a list of functions. Functions can be specified as symbols or\nlambdas.\n\n<pre>[&quot;foo bar&quot;, &quot;baz qux&quot;].map ...</pre>\n"],["has_shape?","Hash","Hash.html#method-i-has_shape-3F","(shape)","<p>Checks if a hash has a certain structure.\n\n<pre>h = { k1: 1, k2: &quot;1&quot; }\nh.has_shape?(k1: Fixnum, k2: String) ...</pre>\n"],["it","Object","Object.html#method-i-it","()","<p>An identity method that provides access to an object’s <code>self</code>.\n\n<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>(&amp;:<span class=\"ruby-identifier\">it</span>)\n<span class=\"ruby-comment\">#=&gt; {1=&gt;[1, ...</span>\n</pre>\n"],["prompt","Kernel","Kernel.html#method-i-prompt","(text='', conversion=nil)","<p>Displays a prompt and returns chomped input. Modelled after the Python\nmethod <code>raw_input</code>, but also can …\n"],["random_subarray","Array","Array.html#method-i-random_subarray","(n=1)","<p>Generates random subarrays. Uses random numbers and bit-fiddling to assure\nperformant uniform distributions …\n"],["string_length","Fixnum","Fixnum.html#method-i-string_length","()","<p>Returns the lenth of the number’s string representation\n\n<pre class=\"ruby\"><span class=\"ruby-value\">0</span>.<span class=\"ruby-identifier\">string_length</span>\n<span class=\"ruby-comment\">#=&gt; 1</span>\n<span class=\"ruby-value\">123</span>.<span class=\"ruby-identifier\">string_length</span>\n<span class=\"ruby-comment\">#=&gt; 3 ...</span>\n</pre>\n"],["to_ostruct","Hash","Hash.html#method-i-to_ostruct","()","<p>Recursively converts a <code>Hash</code> and all nested <code>Hash</code>es\nto <code>OpenStruct</code>s. Especially useful for parsing YAML …\n"],["with","Kernel","Kernel.html#method-i-with","(o, &blk)","<p>A Pascal/ActionScript like <code>with</code> method. Yields its argument to\nthe provided block and then returns it. …\n"],["zip_with","Array","Array.html#method-i-zip_with","(other, op=nil)","<p>Zip <code>self</code> with <code>other</code>, combining the elements with\nthe provided block or symbol. The resulting array will …\n"],["README","","README_rdoc.html","","<p>Shenanigans\n<p><strong>shenanigan</strong> (plural shenanigans):\n<p>Trickery, games; skulduggery. To “call”, “claim” …\n"]]}}
@@ -46,6 +46,9 @@
46
46
  <ul>
47
47
  <li class="class">
48
48
  <a href="Array.html">Array</a>
49
+ </li>
50
+ <li class="class">
51
+ <a href="Fixnum.html">Fixnum</a>
49
52
  </li>
50
53
  <li class="class">
51
54
  <a href="Hash.html">Hash</a>
@@ -72,12 +75,14 @@
72
75
 
73
76
  <li class="method"><a href="Hash.html#method-i-has_shape-3F">#has_shape? &mdash; Hash</a>
74
77
 
75
- <li class="method"><a href="Object.html#method-i-identity">#identity &mdash; Object</a>
78
+ <li class="method"><a href="Object.html#method-i-it">#it &mdash; Object</a>
76
79
 
77
80
  <li class="method"><a href="Kernel.html#method-i-prompt">#prompt &mdash; Kernel</a>
78
81
 
79
82
  <li class="method"><a href="Array.html#method-i-random_subarray">#random_subarray &mdash; Array</a>
80
83
 
84
+ <li class="method"><a href="Fixnum.html#method-i-string_length">#string_length &mdash; Fixnum</a>
85
+
81
86
  <li class="method"><a href="Hash.html#method-i-to_ostruct">#to_ostruct &mdash; Hash</a>
82
87
 
83
88
  <li class="method"><a href="Kernel.html#method-i-with">#with &mdash; Kernel</a>
@@ -2,3 +2,4 @@ require 'shenanigans/array'
2
2
  require 'shenanigans/hash'
3
3
  require 'shenanigans/kernel'
4
4
  require 'shenanigans/object'
5
+ require 'shenanigans/fixnum'
@@ -3,6 +3,6 @@ class Array
3
3
  # [1, 2, 3] ^ [1, 2, 4]
4
4
  # #=> [3, 4]
5
5
  def ^(other)
6
- (self | other) - (self & other)
6
+ (self - other) | (other - self)
7
7
  end
8
8
  end
@@ -0,0 +1 @@
1
+ require_relative 'fixnum/string_length'
@@ -0,0 +1,14 @@
1
+ class Fixnum
2
+ # Returns the length of the number's string representation.
3
+ # 0.string_length
4
+ # #=> 1
5
+ # 123.string_length
6
+ # #=> 3
7
+ # -1.string_length
8
+ # #=> 2
9
+ def string_length
10
+ return 1 if self.zero?
11
+ len = Math.log10(self.abs).floor.next
12
+ self > 0 ? len : len.next
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ require 'minitest/autorun'
2
+ require 'shenanigans/fixnum/string_length'
3
+
4
+ class StringLength < MiniTest::Unit::TestCase
5
+ def test_zero
6
+ assert 0.string_length == 1
7
+ end
8
+
9
+ def test_positive
10
+ assert 123.string_length == 3
11
+ end
12
+
13
+ def test_negative
14
+ assert -1.string_length == 2
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shenanigans
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-28 00:00:00.000000000 Z
12
+ date: 2012-07-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: citizen428@gmail.com
@@ -22,6 +22,7 @@ files:
22
22
  - README.rdoc
23
23
  - doc/Array.html
24
24
  - doc/created.rid
25
+ - doc/Fixnum.html
25
26
  - doc/Hash.html
26
27
  - doc/images/add.png
27
28
  - doc/images/brick.png
@@ -63,6 +64,8 @@ files:
63
64
  - lib/shenanigans/array/random_subarray.rb
64
65
  - lib/shenanigans/array/zip_with.rb
65
66
  - lib/shenanigans/array.rb
67
+ - lib/shenanigans/fixnum/string_length.rb
68
+ - lib/shenanigans/fixnum.rb
66
69
  - lib/shenanigans/hash/has_shape_pred.rb
67
70
  - lib/shenanigans/hash/to_ostruct.rb
68
71
  - lib/shenanigans/hash.rb
@@ -74,11 +77,11 @@ files:
74
77
  - lib/shenanigans/object/it.rb
75
78
  - lib/shenanigans/object.rb
76
79
  - lib/shenanigans/README.mdown
77
- - lib/shenanigans/shenanigans-0.0.1.gem
78
80
  - lib/shenanigans.rb
79
81
  - test/array/test_caret.rb
80
82
  - test/array/test_random_subarray.rb
81
83
  - test/array/test_zip_with.rb
84
+ - test/fixnum/test_string_length.rb
82
85
  - test/hash/test_has_shape_pred.rb
83
86
  - test/hash/test_to_ostruct.rb
84
87
  - test/kernel/test_fn.rb