blackbox 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/coverage/.resultset.json +1 -2
- data/coverage/index.html +123 -129
- data/doc/BB.html +2 -2
- data/doc/BB/Crypto.html +1 -1
- data/doc/BB/Hash.html +1 -1
- data/doc/BB/Number.html +22 -24
- data/doc/BB/String.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/blackbox.rb +1 -0
- data/lib/blackbox/number.rb +12 -13
- data/lib/blackbox/version.rb +1 -1
- metadata +1 -1
data/doc/BB.html
CHANGED
@@ -104,7 +104,7 @@
|
|
104
104
|
<dt id="VERSION-constant" class="">VERSION =
|
105
105
|
|
106
106
|
</dt>
|
107
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>1.1.
|
107
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>1.1.2</span><span class='tstring_end'>"</span></span></pre></dd>
|
108
108
|
|
109
109
|
</dl>
|
110
110
|
|
@@ -120,7 +120,7 @@
|
|
120
120
|
</div>
|
121
121
|
|
122
122
|
<div id="footer">
|
123
|
-
Generated on Sun Nov 22 18:
|
123
|
+
Generated on Sun Nov 22 18:39:44 2015 by
|
124
124
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
125
125
|
0.8.5.2 (ruby-2.2.2).
|
126
126
|
</div>
|
data/doc/BB/Crypto.html
CHANGED
@@ -1136,7 +1136,7 @@
|
|
1136
1136
|
</div>
|
1137
1137
|
|
1138
1138
|
<div id="footer">
|
1139
|
-
Generated on Sun Nov 22 18:
|
1139
|
+
Generated on Sun Nov 22 18:39:45 2015 by
|
1140
1140
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1141
1141
|
0.8.5.2 (ruby-2.2.2).
|
1142
1142
|
</div>
|
data/doc/BB/Hash.html
CHANGED
@@ -432,7 +432,7 @@ BB::Hash.flatten_prop_style(input)
|
|
432
432
|
</div>
|
433
433
|
|
434
434
|
<div id="footer">
|
435
|
-
Generated on Sun Nov 22 18:
|
435
|
+
Generated on Sun Nov 22 18:39:44 2015 by
|
436
436
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
437
437
|
0.8.5.2 (ruby-2.2.2).
|
438
438
|
</div>
|
data/doc/BB/Number.html
CHANGED
@@ -141,7 +141,7 @@
|
|
141
141
|
|
142
142
|
<span class="summary_desc"><div class='inline'>
|
143
143
|
<p>Formats the bytes in <code>size</code> into a more understandable
|
144
|
-
representation (e.g., giving it 1500 yields 1.
|
144
|
+
representation (e.g., giving it 1500 yields 1.5k).</p>
|
145
145
|
</div></span>
|
146
146
|
|
147
147
|
</li>
|
@@ -219,7 +219,7 @@ representation (e.g., giving it 1500 yields 1.5 KB).</p>
|
|
219
219
|
<div class="discussion">
|
220
220
|
|
221
221
|
<p>Formats the bytes in <code>size</code> into a more understandable
|
222
|
-
representation (e.g., giving it 1500 yields 1.
|
222
|
+
representation (e.g., giving it 1500 yields 1.5k). This method is useful
|
223
223
|
for reporting file sizes to users. This method returns nil if
|
224
224
|
<code>size</code> cannot be converted into a number. You can customize the
|
225
225
|
format in the <code>options</code> hash.</p>
|
@@ -233,15 +233,15 @@ format in the <code>options</code> hash.</p>
|
|
233
233
|
<p class="tag_title">Examples:</p>
|
234
234
|
|
235
235
|
|
236
|
-
<pre class="example code"><code><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>123</span><span class='rparen'>)</span> <span class='comment'># => 123
|
237
|
-
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>1234</span><span class='rparen'>)</span> <span class='comment'># => 1.
|
238
|
-
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>12345</span><span class='rparen'>)</span> <span class='comment'># => 12.
|
239
|
-
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>1234567</span><span class='rparen'>)</span> <span class='comment'># => 1.
|
240
|
-
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>1234567890</span><span class='rparen'>)</span> <span class='comment'># => 1.
|
241
|
-
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>1234567890123</span><span class='rparen'>)</span> <span class='comment'># => 1.
|
242
|
-
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>1234567</span><span class='comma'>,</span> <span class='symbol'>:precision</span> <span class='op'>=></span> <span class='int'>2</span><span class='rparen'>)</span> <span class='comment'># => 1.
|
243
|
-
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>483989</span><span class='comma'>,</span> <span class='symbol'>:precision</span> <span class='op'>=></span> <span class='int'>0</span><span class='rparen'>)</span> <span class='comment'># =>
|
244
|
-
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>1234567</span><span class='comma'>,</span> <span class='symbol'>:precision</span> <span class='op'>=></span> <span class='int'>2</span><span class='comma'>,</span> <span class='symbol'>:separator</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>,</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'># => 1,
|
236
|
+
<pre class="example code"><code><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>123</span><span class='rparen'>)</span> <span class='comment'># => 123
|
237
|
+
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>1234</span><span class='rparen'>)</span> <span class='comment'># => 1.2k
|
238
|
+
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>12345</span><span class='rparen'>)</span> <span class='comment'># => 12.1k
|
239
|
+
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>1234567</span><span class='rparen'>)</span> <span class='comment'># => 1.2M
|
240
|
+
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>1234567890</span><span class='rparen'>)</span> <span class='comment'># => 1.1G
|
241
|
+
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>1234567890123</span><span class='rparen'>)</span> <span class='comment'># => 1.1T
|
242
|
+
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>1234567</span><span class='comma'>,</span> <span class='symbol'>:precision</span> <span class='op'>=></span> <span class='int'>2</span><span class='rparen'>)</span> <span class='comment'># => 1.18M
|
243
|
+
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>483989</span><span class='comma'>,</span> <span class='symbol'>:precision</span> <span class='op'>=></span> <span class='int'>0</span><span class='rparen'>)</span> <span class='comment'># => 473k
|
244
|
+
</span><span class='id identifier rubyid_to_human_size'>to_human_size</span><span class='lparen'>(</span><span class='int'>1234567</span><span class='comma'>,</span> <span class='symbol'>:precision</span> <span class='op'>=></span> <span class='int'>2</span><span class='comma'>,</span> <span class='symbol'>:separator</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>,</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'># => 1,18M</span></code></pre>
|
245
245
|
|
246
246
|
</div>
|
247
247
|
|
@@ -369,7 +369,7 @@ format in the <code>options</code> hash.</p>
|
|
369
369
|
<span class="default">
|
370
370
|
|
371
371
|
— default:
|
372
|
-
<tt>"%n
|
372
|
+
<tt>"%n%u"</tt>
|
373
373
|
|
374
374
|
</span>
|
375
375
|
|
@@ -444,8 +444,7 @@ format in the <code>options</code> hash.</p>
|
|
444
444
|
76
|
445
445
|
77
|
446
446
|
78
|
447
|
-
79
|
448
|
-
80</pre>
|
447
|
+
79</pre>
|
449
448
|
</td>
|
450
449
|
<td>
|
451
450
|
<pre class="code"><span class="info file"># File 'lib/blackbox/number.rb', line 45</span>
|
@@ -462,12 +461,11 @@ format in the <code>options</code> hash.</p>
|
|
462
461
|
<span class='id identifier rubyid_storage_units_format'>storage_units_format</span> <span class='op'>||=</span> <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:format</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%n%u</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
463
462
|
|
464
463
|
<span class='kw'>if</span> <span class='id identifier rubyid_number'>number</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'><</span> <span class='id identifier rubyid_kilo'>kilo</span>
|
465
|
-
<span class='
|
466
|
-
</span> <span class='id identifier rubyid_storage_units_format'>storage_units_format</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>%n</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='id identifier rubyid_number'>number</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>%u</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
464
|
+
<span class='id identifier rubyid_storage_units_format'>storage_units_format</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>%n</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='id identifier rubyid_number'>number</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>%u</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
467
465
|
<span class='kw'>else</span>
|
468
466
|
<span class='id identifier rubyid_max_exp'>max_exp</span> <span class='op'>=</span> <span class='const'>STORAGE_UNITS</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>-</span> <span class='int'>1</span>
|
469
467
|
<span class='id identifier rubyid_number'>number</span> <span class='op'>=</span> <span class='const'>Float</span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span><span class='rparen'>)</span>
|
470
|
-
<span class='id identifier rubyid_exponent'>exponent</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='const'>Math</span><span class='period'>.</span><span class='id identifier rubyid_log'>log</span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span><span class='rparen'>)</span> <span class='op'>/</span> <span class='const'>Math</span><span class='period'>.</span><span class='id identifier rubyid_log'>log</span><span class='lparen'>(</span><span class='id identifier rubyid_kilo'>kilo</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='comment'># Convert to base
|
468
|
+
<span class='id identifier rubyid_exponent'>exponent</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='const'>Math</span><span class='period'>.</span><span class='id identifier rubyid_log'>log</span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span><span class='rparen'>)</span> <span class='op'>/</span> <span class='const'>Math</span><span class='period'>.</span><span class='id identifier rubyid_log'>log</span><span class='lparen'>(</span><span class='id identifier rubyid_kilo'>kilo</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='comment'># Convert to base
|
471
469
|
</span> <span class='id identifier rubyid_exponent'>exponent</span> <span class='op'>=</span> <span class='id identifier rubyid_max_exp'>max_exp</span> <span class='kw'>if</span> <span class='id identifier rubyid_exponent'>exponent</span> <span class='op'>></span> <span class='id identifier rubyid_max_exp'>max_exp</span> <span class='comment'># we need this to avoid overflow for the highest unit
|
472
470
|
</span> <span class='id identifier rubyid_number'>number</span> <span class='op'>/=</span> <span class='id identifier rubyid_kilo'>kilo</span> <span class='op'>**</span> <span class='id identifier rubyid_exponent'>exponent</span>
|
473
471
|
|
@@ -642,6 +640,7 @@ format in the <code>options</code> hash.</p>
|
|
642
640
|
<pre class="lines">
|
643
641
|
|
644
642
|
|
643
|
+
148
|
645
644
|
149
|
646
645
|
150
|
647
646
|
151
|
@@ -654,11 +653,10 @@ format in the <code>options</code> hash.</p>
|
|
654
653
|
158
|
655
654
|
159
|
656
655
|
160
|
657
|
-
161
|
658
|
-
162</pre>
|
656
|
+
161</pre>
|
659
657
|
</td>
|
660
658
|
<td>
|
661
|
-
<pre class="code"><span class="info file"># File 'lib/blackbox/number.rb', line
|
659
|
+
<pre class="code"><span class="info file"># File 'lib/blackbox/number.rb', line 148</span>
|
662
660
|
|
663
661
|
<span class='kw'>def</span> <span class='id identifier rubyid_with_delimiter'>with_delimiter</span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
664
662
|
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='const'>BB</span><span class='op'>::</span><span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_symbolize_keys'>symbolize_keys</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
@@ -846,6 +844,7 @@ customize the format in the <code>options</code> hash.</p>
|
|
846
844
|
<pre class="lines">
|
847
845
|
|
848
846
|
|
847
|
+
107
|
849
848
|
108
|
850
849
|
109
|
851
850
|
110
|
@@ -860,11 +859,10 @@ customize the format in the <code>options</code> hash.</p>
|
|
860
859
|
119
|
861
860
|
120
|
862
861
|
121
|
863
|
-
122
|
864
|
-
123</pre>
|
862
|
+
122</pre>
|
865
863
|
</td>
|
866
864
|
<td>
|
867
|
-
<pre class="code"><span class="info file"># File 'lib/blackbox/number.rb', line
|
865
|
+
<pre class="code"><span class="info file"># File 'lib/blackbox/number.rb', line 107</span>
|
868
866
|
|
869
867
|
<span class='kw'>def</span> <span class='id identifier rubyid_with_precision'>with_precision</span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
870
868
|
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='const'>BB</span><span class='op'>::</span><span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_symbolize_keys'>symbolize_keys</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
@@ -892,7 +890,7 @@ customize the format in the <code>options</code> hash.</p>
|
|
892
890
|
</div>
|
893
891
|
|
894
892
|
<div id="footer">
|
895
|
-
Generated on Sun Nov 22 18:
|
893
|
+
Generated on Sun Nov 22 18:39:44 2015 by
|
896
894
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
897
895
|
0.8.5.2 (ruby-2.2.2).
|
898
896
|
</div>
|
data/doc/BB/String.html
CHANGED
@@ -231,7 +231,7 @@
|
|
231
231
|
</div>
|
232
232
|
|
233
233
|
<div id="footer">
|
234
|
-
Generated on Sun Nov 22 18:
|
234
|
+
Generated on Sun Nov 22 18:39:44 2015 by
|
235
235
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
236
236
|
0.8.5.2 (ruby-2.2.2).
|
237
237
|
</div>
|
data/doc/_index.html
CHANGED
@@ -161,7 +161,7 @@
|
|
161
161
|
</div>
|
162
162
|
|
163
163
|
<div id="footer">
|
164
|
-
Generated on Sun Nov 22 18:
|
164
|
+
Generated on Sun Nov 22 18:39:44 2015 by
|
165
165
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
166
166
|
0.8.5.2 (ruby-2.2.2).
|
167
167
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -95,7 +95,7 @@ BB::String.strip_ansi( ... )
|
|
95
95
|
</div></div>
|
96
96
|
|
97
97
|
<div id="footer">
|
98
|
-
Generated on Sun Nov 22 18:
|
98
|
+
Generated on Sun Nov 22 18:39:44 2015 by
|
99
99
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
100
100
|
0.8.5.2 (ruby-2.2.2).
|
101
101
|
</div>
|
data/doc/index.html
CHANGED
@@ -95,7 +95,7 @@ BB::String.strip_ansi( ... )
|
|
95
95
|
</div></div>
|
96
96
|
|
97
97
|
<div id="footer">
|
98
|
-
Generated on Sun Nov 22 18:
|
98
|
+
Generated on Sun Nov 22 18:39:44 2015 by
|
99
99
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
100
100
|
0.8.5.2 (ruby-2.2.2).
|
101
101
|
</div>
|
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on Sun Nov 22 18:
|
106
|
+
Generated on Sun Nov 22 18:39:44 2015 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.8.5.2 (ruby-2.2.2).
|
109
109
|
</div>
|
data/lib/blackbox.rb
CHANGED
data/lib/blackbox/number.rb
CHANGED
@@ -8,7 +8,7 @@ module BB
|
|
8
8
|
|
9
9
|
##
|
10
10
|
# Formats the bytes in +size+ into a more understandable representation
|
11
|
-
# (e.g., giving it 1500 yields 1.
|
11
|
+
# (e.g., giving it 1500 yields 1.5k). This method is useful for
|
12
12
|
# reporting file sizes to users. This method returns nil if
|
13
13
|
# +size+ cannot be converted into a number. You can customize the
|
14
14
|
# format in the +options+ hash.
|
@@ -26,21 +26,21 @@ module BB
|
|
26
26
|
# Sets the thousands delimiter.
|
27
27
|
# @option options [String] :kilo (1024)
|
28
28
|
# Sets the number of bytes in a kilobyte.
|
29
|
-
# @option options [String] :format ("%n
|
29
|
+
# @option options [String] :format ("%n%u")
|
30
30
|
# Sets the display format.
|
31
31
|
#
|
32
32
|
# @return [String] The formatted representation of bytes
|
33
33
|
#
|
34
34
|
# @example
|
35
|
-
# to_human_size(123) # => 123
|
36
|
-
# to_human_size(1234) # => 1.
|
37
|
-
# to_human_size(12345) # => 12.
|
38
|
-
# to_human_size(1234567) # => 1.
|
39
|
-
# to_human_size(1234567890) # => 1.
|
40
|
-
# to_human_size(1234567890123) # => 1.
|
41
|
-
# to_human_size(1234567, :precision => 2) # => 1.
|
42
|
-
# to_human_size(483989, :precision => 0) # =>
|
43
|
-
# to_human_size(1234567, :precision => 2, :separator => ',') # => 1,
|
35
|
+
# to_human_size(123) # => 123
|
36
|
+
# to_human_size(1234) # => 1.2k
|
37
|
+
# to_human_size(12345) # => 12.1k
|
38
|
+
# to_human_size(1234567) # => 1.2M
|
39
|
+
# to_human_size(1234567890) # => 1.1G
|
40
|
+
# to_human_size(1234567890123) # => 1.1T
|
41
|
+
# to_human_size(1234567, :precision => 2) # => 1.18M
|
42
|
+
# to_human_size(483989, :precision => 0) # => 473k
|
43
|
+
# to_human_size(1234567, :precision => 2, :separator => ',') # => 1,18M
|
44
44
|
#
|
45
45
|
def to_human_size(number, args={})
|
46
46
|
return nil if number.nil?
|
@@ -54,12 +54,11 @@ module BB
|
|
54
54
|
storage_units_format ||= (options[:format] || '%n%u')
|
55
55
|
|
56
56
|
if number.to_i < kilo
|
57
|
-
#unit = I18n.translate(:'number.human.storage_units.units.byte', :locale => options[:locale], :count => number.to_i, :raise => true)
|
58
57
|
storage_units_format.gsub(/%n/, number.to_i.to_s).gsub(/%u/, '')
|
59
58
|
else
|
60
59
|
max_exp = STORAGE_UNITS.size - 1
|
61
60
|
number = Float(number)
|
62
|
-
exponent = (Math.log(number) / Math.log(kilo)).to_i # Convert to base
|
61
|
+
exponent = (Math.log(number) / Math.log(kilo)).to_i # Convert to base
|
63
62
|
exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit
|
64
63
|
number /= kilo ** exponent
|
65
64
|
|
data/lib/blackbox/version.rb
CHANGED