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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b059890b91c50df09f0db93023f6548950127ba2
|
4
|
+
data.tar.gz: 95552bbaef2c3dac13097c37545e767c3776b7ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0258b2e92074f7394dea6e2824bbd16973561dc585be74048c8ceea792caa2d8547ab6fd7acb1d422e7fd63937a0ff2a3ebc199672831173926e709f7bfcba62
|
7
|
+
data.tar.gz: e4a411a37a6c189417422f2c181328ac0d47e4f2cfee872a529d5699f9368d2948298cdcb00ce6fbacf239c35baee4ae2976e8aceb227c9b4574015a6e11f562
|
data/coverage/.resultset.json
CHANGED
data/coverage/index.html
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
<img src="./assets/0.7.1/loading.gif" alt="loading"/>
|
15
15
|
</div>
|
16
16
|
<div id="wrapper" style="display:none;">
|
17
|
-
<div class="timestamp">Generated <abbr class="timeago" title="2015-11-22T18:
|
17
|
+
<div class="timestamp">Generated <abbr class="timeago" title="2015-11-22T18:39:43+01:00">2015-11-22T18:39:43+01:00</abbr></div>
|
18
18
|
<ul class="group_tabs"></ul>
|
19
19
|
|
20
20
|
<div id="content">
|
@@ -73,7 +73,7 @@
|
|
73
73
|
<tr>
|
74
74
|
<td class="strong"><a href="#7a135b0407697dbb00ab589a4ca6477d724b7276" class="src_link" title="lib/blackbox/number.rb">lib/blackbox/number.rb</a></td>
|
75
75
|
<td class="green strong">91.11 %</td>
|
76
|
-
<td>
|
76
|
+
<td>165</td>
|
77
77
|
<td>45</td>
|
78
78
|
<td>41</td>
|
79
79
|
<td>4</td>
|
@@ -1107,7 +1107,7 @@
|
|
1107
1107
|
<li class="never" data-hits="" data-linenumber="11">
|
1108
1108
|
|
1109
1109
|
|
1110
|
-
<code class="ruby"> # (e.g., giving it 1500 yields 1.
|
1110
|
+
<code class="ruby"> # (e.g., giving it 1500 yields 1.5k). This method is useful for</code>
|
1111
1111
|
</li>
|
1112
1112
|
|
1113
1113
|
<li class="never" data-hits="" data-linenumber="12">
|
@@ -1215,7 +1215,7 @@
|
|
1215
1215
|
<li class="never" data-hits="" data-linenumber="29">
|
1216
1216
|
|
1217
1217
|
|
1218
|
-
<code class="ruby"> # @option options [String] :format ("%n
|
1218
|
+
<code class="ruby"> # @option options [String] :format ("%n%u")</code>
|
1219
1219
|
</li>
|
1220
1220
|
|
1221
1221
|
<li class="never" data-hits="" data-linenumber="30">
|
@@ -1251,55 +1251,55 @@
|
|
1251
1251
|
<li class="never" data-hits="" data-linenumber="35">
|
1252
1252
|
|
1253
1253
|
|
1254
|
-
<code class="ruby"> # to_human_size(123) # => 123
|
1254
|
+
<code class="ruby"> # to_human_size(123) # => 123</code>
|
1255
1255
|
</li>
|
1256
1256
|
|
1257
1257
|
<li class="never" data-hits="" data-linenumber="36">
|
1258
1258
|
|
1259
1259
|
|
1260
|
-
<code class="ruby"> # to_human_size(1234) # => 1.
|
1260
|
+
<code class="ruby"> # to_human_size(1234) # => 1.2k</code>
|
1261
1261
|
</li>
|
1262
1262
|
|
1263
1263
|
<li class="never" data-hits="" data-linenumber="37">
|
1264
1264
|
|
1265
1265
|
|
1266
|
-
<code class="ruby"> # to_human_size(12345) # => 12.
|
1266
|
+
<code class="ruby"> # to_human_size(12345) # => 12.1k</code>
|
1267
1267
|
</li>
|
1268
1268
|
|
1269
1269
|
<li class="never" data-hits="" data-linenumber="38">
|
1270
1270
|
|
1271
1271
|
|
1272
|
-
<code class="ruby"> # to_human_size(1234567) # => 1.
|
1272
|
+
<code class="ruby"> # to_human_size(1234567) # => 1.2M</code>
|
1273
1273
|
</li>
|
1274
1274
|
|
1275
1275
|
<li class="never" data-hits="" data-linenumber="39">
|
1276
1276
|
|
1277
1277
|
|
1278
|
-
<code class="ruby"> # to_human_size(1234567890) # => 1.
|
1278
|
+
<code class="ruby"> # to_human_size(1234567890) # => 1.1G</code>
|
1279
1279
|
</li>
|
1280
1280
|
|
1281
1281
|
<li class="never" data-hits="" data-linenumber="40">
|
1282
1282
|
|
1283
1283
|
|
1284
|
-
<code class="ruby"> # to_human_size(1234567890123) # => 1.
|
1284
|
+
<code class="ruby"> # to_human_size(1234567890123) # => 1.1T</code>
|
1285
1285
|
</li>
|
1286
1286
|
|
1287
1287
|
<li class="never" data-hits="" data-linenumber="41">
|
1288
1288
|
|
1289
1289
|
|
1290
|
-
<code class="ruby"> # to_human_size(1234567, :precision => 2) # => 1.
|
1290
|
+
<code class="ruby"> # to_human_size(1234567, :precision => 2) # => 1.18M</code>
|
1291
1291
|
</li>
|
1292
1292
|
|
1293
1293
|
<li class="never" data-hits="" data-linenumber="42">
|
1294
1294
|
|
1295
1295
|
|
1296
|
-
<code class="ruby"> # to_human_size(483989, :precision => 0) # =>
|
1296
|
+
<code class="ruby"> # to_human_size(483989, :precision => 0) # => 473k</code>
|
1297
1297
|
</li>
|
1298
1298
|
|
1299
1299
|
<li class="never" data-hits="" data-linenumber="43">
|
1300
1300
|
|
1301
1301
|
|
1302
|
-
<code class="ruby"> # to_human_size(1234567, :precision => 2, :separator => ',') # => 1,
|
1302
|
+
<code class="ruby"> # to_human_size(1234567, :precision => 2, :separator => ',') # => 1,18M</code>
|
1303
1303
|
</li>
|
1304
1304
|
|
1305
1305
|
<li class="never" data-hits="" data-linenumber="44">
|
@@ -1380,661 +1380,655 @@
|
|
1380
1380
|
<code class="ruby"> if number.to_i < kilo</code>
|
1381
1381
|
</li>
|
1382
1382
|
|
1383
|
-
<li class="
|
1384
|
-
|
1385
|
-
|
1386
|
-
<code class="ruby"> #unit = I18n.translate(:'number.human.storage_units.units.byte', :locale => options[:locale], :count => number.to_i, :raise => true)</code>
|
1387
|
-
</li>
|
1388
|
-
|
1389
|
-
<li class="covered" data-hits="1" data-linenumber="58">
|
1383
|
+
<li class="covered" data-hits="1" data-linenumber="57">
|
1390
1384
|
<span class="hits">1</span>
|
1391
1385
|
|
1392
1386
|
<code class="ruby"> storage_units_format.gsub(/%n/, number.to_i.to_s).gsub(/%u/, '')</code>
|
1393
1387
|
</li>
|
1394
1388
|
|
1395
|
-
<li class="never" data-hits="" data-linenumber="
|
1389
|
+
<li class="never" data-hits="" data-linenumber="58">
|
1396
1390
|
|
1397
1391
|
|
1398
1392
|
<code class="ruby"> else</code>
|
1399
1393
|
</li>
|
1400
1394
|
|
1401
|
-
<li class="covered" data-hits="10" data-linenumber="
|
1395
|
+
<li class="covered" data-hits="10" data-linenumber="59">
|
1402
1396
|
<span class="hits">10</span>
|
1403
1397
|
|
1404
1398
|
<code class="ruby"> max_exp = STORAGE_UNITS.size - 1</code>
|
1405
1399
|
</li>
|
1406
1400
|
|
1407
|
-
<li class="covered" data-hits="10" data-linenumber="
|
1401
|
+
<li class="covered" data-hits="10" data-linenumber="60">
|
1408
1402
|
<span class="hits">10</span>
|
1409
1403
|
|
1410
1404
|
<code class="ruby"> number = Float(number)</code>
|
1411
1405
|
</li>
|
1412
1406
|
|
1413
|
-
<li class="covered" data-hits="10" data-linenumber="
|
1407
|
+
<li class="covered" data-hits="10" data-linenumber="61">
|
1414
1408
|
<span class="hits">10</span>
|
1415
1409
|
|
1416
|
-
<code class="ruby"> exponent = (Math.log(number) / Math.log(kilo)).to_i # Convert to base
|
1410
|
+
<code class="ruby"> exponent = (Math.log(number) / Math.log(kilo)).to_i # Convert to base</code>
|
1417
1411
|
</li>
|
1418
1412
|
|
1419
|
-
<li class="covered" data-hits="10" data-linenumber="
|
1413
|
+
<li class="covered" data-hits="10" data-linenumber="62">
|
1420
1414
|
<span class="hits">10</span>
|
1421
1415
|
|
1422
1416
|
<code class="ruby"> exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit</code>
|
1423
1417
|
</li>
|
1424
1418
|
|
1425
|
-
<li class="covered" data-hits="10" data-linenumber="
|
1419
|
+
<li class="covered" data-hits="10" data-linenumber="63">
|
1426
1420
|
<span class="hits">10</span>
|
1427
1421
|
|
1428
1422
|
<code class="ruby"> number /= kilo ** exponent</code>
|
1429
1423
|
</li>
|
1430
1424
|
|
1431
|
-
<li class="never" data-hits="" data-linenumber="
|
1425
|
+
<li class="never" data-hits="" data-linenumber="64">
|
1432
1426
|
|
1433
1427
|
|
1434
1428
|
<code class="ruby"></code>
|
1435
1429
|
</li>
|
1436
1430
|
|
1437
|
-
<li class="covered" data-hits="10" data-linenumber="
|
1431
|
+
<li class="covered" data-hits="10" data-linenumber="65">
|
1438
1432
|
<span class="hits">10</span>
|
1439
1433
|
|
1440
1434
|
<code class="ruby"> unit = STORAGE_UNITS[exponent]</code>
|
1441
1435
|
</li>
|
1442
1436
|
|
1443
|
-
<li class="never" data-hits="" data-linenumber="
|
1437
|
+
<li class="never" data-hits="" data-linenumber="66">
|
1444
1438
|
|
1445
1439
|
|
1446
1440
|
<code class="ruby"></code>
|
1447
1441
|
</li>
|
1448
1442
|
|
1449
|
-
<li class="covered" data-hits="10" data-linenumber="
|
1443
|
+
<li class="covered" data-hits="10" data-linenumber="67">
|
1450
1444
|
<span class="hits">10</span>
|
1451
1445
|
|
1452
1446
|
<code class="ruby"> begin</code>
|
1453
1447
|
</li>
|
1454
1448
|
|
1455
|
-
<li class="covered" data-hits="10" data-linenumber="
|
1449
|
+
<li class="covered" data-hits="10" data-linenumber="68">
|
1456
1450
|
<span class="hits">10</span>
|
1457
1451
|
|
1458
1452
|
<code class="ruby"> escaped_separator = Regexp.escape(separator)</code>
|
1459
1453
|
</li>
|
1460
1454
|
|
1461
|
-
<li class="covered" data-hits="10" data-linenumber="
|
1455
|
+
<li class="covered" data-hits="10" data-linenumber="69">
|
1462
1456
|
<span class="hits">10</span>
|
1463
1457
|
|
1464
1458
|
<code class="ruby"> formatted_number = with_precision(number,</code>
|
1465
1459
|
</li>
|
1466
1460
|
|
1467
|
-
<li class="never" data-hits="" data-linenumber="
|
1461
|
+
<li class="never" data-hits="" data-linenumber="70">
|
1468
1462
|
|
1469
1463
|
|
1470
1464
|
<code class="ruby"> :precision => precision,</code>
|
1471
1465
|
</li>
|
1472
1466
|
|
1473
|
-
<li class="never" data-hits="" data-linenumber="
|
1467
|
+
<li class="never" data-hits="" data-linenumber="71">
|
1474
1468
|
|
1475
1469
|
|
1476
1470
|
<code class="ruby"> :separator => separator,</code>
|
1477
1471
|
</li>
|
1478
1472
|
|
1479
|
-
<li class="never" data-hits="" data-linenumber="
|
1473
|
+
<li class="never" data-hits="" data-linenumber="72">
|
1480
1474
|
|
1481
1475
|
|
1482
1476
|
<code class="ruby"> :delimiter => delimiter</code>
|
1483
1477
|
</li>
|
1484
1478
|
|
1485
|
-
<li class="never" data-hits="" data-linenumber="
|
1479
|
+
<li class="never" data-hits="" data-linenumber="73">
|
1486
1480
|
|
1487
1481
|
|
1488
1482
|
<code class="ruby"> ).sub(/(#{escaped_separator})(\d*[1-9])?0+\z/, '\1\2').sub(/#{escaped_separator}\z/, '')</code>
|
1489
1483
|
</li>
|
1490
1484
|
|
1491
|
-
<li class="covered" data-hits="10" data-linenumber="
|
1485
|
+
<li class="covered" data-hits="10" data-linenumber="74">
|
1492
1486
|
<span class="hits">10</span>
|
1493
1487
|
|
1494
1488
|
<code class="ruby"> storage_units_format.gsub(/%n/, formatted_number).gsub(/%u/, unit)</code>
|
1495
1489
|
</li>
|
1496
1490
|
|
1497
|
-
<li class="missed" data-hits="0" data-linenumber="
|
1491
|
+
<li class="missed" data-hits="0" data-linenumber="75">
|
1498
1492
|
|
1499
1493
|
|
1500
1494
|
<code class="ruby"> rescue => e</code>
|
1501
1495
|
</li>
|
1502
1496
|
|
1503
|
-
<li class="missed" data-hits="0" data-linenumber="
|
1497
|
+
<li class="missed" data-hits="0" data-linenumber="76">
|
1504
1498
|
|
1505
1499
|
|
1506
1500
|
<code class="ruby"> number</code>
|
1507
1501
|
</li>
|
1508
1502
|
|
1509
|
-
<li class="never" data-hits="" data-linenumber="
|
1503
|
+
<li class="never" data-hits="" data-linenumber="77">
|
1510
1504
|
|
1511
1505
|
|
1512
1506
|
<code class="ruby"> end</code>
|
1513
1507
|
</li>
|
1514
1508
|
|
1515
|
-
<li class="never" data-hits="" data-linenumber="
|
1509
|
+
<li class="never" data-hits="" data-linenumber="78">
|
1516
1510
|
|
1517
1511
|
|
1518
1512
|
<code class="ruby"> end</code>
|
1519
1513
|
</li>
|
1520
1514
|
|
1521
|
-
<li class="never" data-hits="" data-linenumber="
|
1515
|
+
<li class="never" data-hits="" data-linenumber="79">
|
1522
1516
|
|
1523
1517
|
|
1524
1518
|
<code class="ruby"> end</code>
|
1525
1519
|
</li>
|
1526
1520
|
|
1527
|
-
<li class="never" data-hits="" data-linenumber="
|
1521
|
+
<li class="never" data-hits="" data-linenumber="80">
|
1528
1522
|
|
1529
1523
|
|
1530
1524
|
<code class="ruby"></code>
|
1531
1525
|
</li>
|
1532
1526
|
|
1533
|
-
<li class="never" data-hits="" data-linenumber="
|
1527
|
+
<li class="never" data-hits="" data-linenumber="81">
|
1534
1528
|
|
1535
1529
|
|
1536
1530
|
<code class="ruby"> ##</code>
|
1537
1531
|
</li>
|
1538
1532
|
|
1539
|
-
<li class="never" data-hits="" data-linenumber="
|
1533
|
+
<li class="never" data-hits="" data-linenumber="82">
|
1540
1534
|
|
1541
1535
|
|
1542
1536
|
<code class="ruby"> # Formats a +number+ with the specified level of <tt>:precision</tt> (e.g., 112.32 has a precision of 2).</code>
|
1543
1537
|
</li>
|
1544
1538
|
|
1545
|
-
<li class="never" data-hits="" data-linenumber="
|
1539
|
+
<li class="never" data-hits="" data-linenumber="83">
|
1546
1540
|
|
1547
1541
|
|
1548
1542
|
<code class="ruby"> # You can customize the format in the +options+ hash.</code>
|
1549
1543
|
</li>
|
1550
1544
|
|
1551
|
-
<li class="never" data-hits="" data-linenumber="
|
1545
|
+
<li class="never" data-hits="" data-linenumber="84">
|
1552
1546
|
|
1553
1547
|
|
1554
1548
|
<code class="ruby"> #</code>
|
1555
1549
|
</li>
|
1556
1550
|
|
1557
|
-
<li class="never" data-hits="" data-linenumber="
|
1551
|
+
<li class="never" data-hits="" data-linenumber="85">
|
1558
1552
|
|
1559
1553
|
|
1560
1554
|
<code class="ruby"> # @overload with_precision(number, options={})</code>
|
1561
1555
|
</li>
|
1562
1556
|
|
1563
|
-
<li class="never" data-hits="" data-linenumber="
|
1557
|
+
<li class="never" data-hits="" data-linenumber="86">
|
1564
1558
|
|
1565
1559
|
|
1566
1560
|
<code class="ruby"> # @param [Fixnum, Float] number</code>
|
1567
1561
|
</li>
|
1568
1562
|
|
1569
|
-
<li class="never" data-hits="" data-linenumber="
|
1563
|
+
<li class="never" data-hits="" data-linenumber="87">
|
1570
1564
|
|
1571
1565
|
|
1572
1566
|
<code class="ruby"> # Number value to format.</code>
|
1573
1567
|
</li>
|
1574
1568
|
|
1575
|
-
<li class="never" data-hits="" data-linenumber="
|
1569
|
+
<li class="never" data-hits="" data-linenumber="88">
|
1576
1570
|
|
1577
1571
|
|
1578
1572
|
<code class="ruby"> # @param [Hash] options</code>
|
1579
1573
|
</li>
|
1580
1574
|
|
1581
|
-
<li class="never" data-hits="" data-linenumber="
|
1575
|
+
<li class="never" data-hits="" data-linenumber="89">
|
1582
1576
|
|
1583
1577
|
|
1584
1578
|
<code class="ruby"> # Options for formatter.</code>
|
1585
1579
|
</li>
|
1586
1580
|
|
1587
|
-
<li class="never" data-hits="" data-linenumber="
|
1581
|
+
<li class="never" data-hits="" data-linenumber="90">
|
1588
1582
|
|
1589
1583
|
|
1590
1584
|
<code class="ruby"> # @option options [Fixnum] :precision (3)</code>
|
1591
1585
|
</li>
|
1592
1586
|
|
1593
|
-
<li class="never" data-hits="" data-linenumber="
|
1587
|
+
<li class="never" data-hits="" data-linenumber="91">
|
1594
1588
|
|
1595
1589
|
|
1596
1590
|
<code class="ruby"> # Sets the level of precision.</code>
|
1597
1591
|
</li>
|
1598
1592
|
|
1599
|
-
<li class="never" data-hits="" data-linenumber="
|
1593
|
+
<li class="never" data-hits="" data-linenumber="92">
|
1600
1594
|
|
1601
1595
|
|
1602
1596
|
<code class="ruby"> # @option options [String] :separator (".")</code>
|
1603
1597
|
</li>
|
1604
1598
|
|
1605
|
-
<li class="never" data-hits="" data-linenumber="
|
1599
|
+
<li class="never" data-hits="" data-linenumber="93">
|
1606
1600
|
|
1607
1601
|
|
1608
1602
|
<code class="ruby"> # Sets the separator between the units.</code>
|
1609
1603
|
</li>
|
1610
1604
|
|
1611
|
-
<li class="never" data-hits="" data-linenumber="
|
1605
|
+
<li class="never" data-hits="" data-linenumber="94">
|
1612
1606
|
|
1613
1607
|
|
1614
1608
|
<code class="ruby"> # @option options [String] :delimiter ("")</code>
|
1615
1609
|
</li>
|
1616
1610
|
|
1617
|
-
<li class="never" data-hits="" data-linenumber="
|
1611
|
+
<li class="never" data-hits="" data-linenumber="95">
|
1618
1612
|
|
1619
1613
|
|
1620
1614
|
<code class="ruby"> # Sets the thousands delimiter.</code>
|
1621
1615
|
</li>
|
1622
1616
|
|
1623
|
-
<li class="never" data-hits="" data-linenumber="
|
1617
|
+
<li class="never" data-hits="" data-linenumber="96">
|
1624
1618
|
|
1625
1619
|
|
1626
1620
|
<code class="ruby"> #</code>
|
1627
1621
|
</li>
|
1628
1622
|
|
1629
|
-
<li class="never" data-hits="" data-linenumber="
|
1623
|
+
<li class="never" data-hits="" data-linenumber="97">
|
1630
1624
|
|
1631
1625
|
|
1632
1626
|
<code class="ruby"> # @return [String] The formatted representation of the number.</code>
|
1633
1627
|
</li>
|
1634
1628
|
|
1635
|
-
<li class="never" data-hits="" data-linenumber="
|
1629
|
+
<li class="never" data-hits="" data-linenumber="98">
|
1636
1630
|
|
1637
1631
|
|
1638
1632
|
<code class="ruby"> #</code>
|
1639
1633
|
</li>
|
1640
1634
|
|
1641
|
-
<li class="never" data-hits="" data-linenumber="
|
1635
|
+
<li class="never" data-hits="" data-linenumber="99">
|
1642
1636
|
|
1643
1637
|
|
1644
1638
|
<code class="ruby"> # @example</code>
|
1645
1639
|
</li>
|
1646
1640
|
|
1647
|
-
<li class="never" data-hits="" data-linenumber="
|
1641
|
+
<li class="never" data-hits="" data-linenumber="100">
|
1648
1642
|
|
1649
1643
|
|
1650
1644
|
<code class="ruby"> # with_precision(111.2345) # => 111.235</code>
|
1651
1645
|
</li>
|
1652
1646
|
|
1653
|
-
<li class="never" data-hits="" data-linenumber="
|
1647
|
+
<li class="never" data-hits="" data-linenumber="101">
|
1654
1648
|
|
1655
1649
|
|
1656
1650
|
<code class="ruby"> # with_precision(111.2345, :precision => 2) # => 111.23</code>
|
1657
1651
|
</li>
|
1658
1652
|
|
1659
|
-
<li class="never" data-hits="" data-linenumber="
|
1653
|
+
<li class="never" data-hits="" data-linenumber="102">
|
1660
1654
|
|
1661
1655
|
|
1662
1656
|
<code class="ruby"> # with_precision(13, :precision => 5) # => 13.00000</code>
|
1663
1657
|
</li>
|
1664
1658
|
|
1665
|
-
<li class="never" data-hits="" data-linenumber="
|
1659
|
+
<li class="never" data-hits="" data-linenumber="103">
|
1666
1660
|
|
1667
1661
|
|
1668
1662
|
<code class="ruby"> # with_precision(389.32314, :precision => 0) # => 389</code>
|
1669
1663
|
</li>
|
1670
1664
|
|
1671
|
-
<li class="never" data-hits="" data-linenumber="
|
1665
|
+
<li class="never" data-hits="" data-linenumber="104">
|
1672
1666
|
|
1673
1667
|
|
1674
1668
|
<code class="ruby"> # with_precision(1111.2345, :precision => 2, :separator => ',', :delimiter => '.')</code>
|
1675
1669
|
</li>
|
1676
1670
|
|
1677
|
-
<li class="never" data-hits="" data-linenumber="
|
1671
|
+
<li class="never" data-hits="" data-linenumber="105">
|
1678
1672
|
|
1679
1673
|
|
1680
1674
|
<code class="ruby"> # # => 1.111,23</code>
|
1681
1675
|
</li>
|
1682
1676
|
|
1683
|
-
<li class="never" data-hits="" data-linenumber="
|
1677
|
+
<li class="never" data-hits="" data-linenumber="106">
|
1684
1678
|
|
1685
1679
|
|
1686
1680
|
<code class="ruby"> #</code>
|
1687
1681
|
</li>
|
1688
1682
|
|
1689
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1683
|
+
<li class="covered" data-hits="1" data-linenumber="107">
|
1690
1684
|
<span class="hits">1</span>
|
1691
1685
|
|
1692
1686
|
<code class="ruby"> def with_precision(number, args)</code>
|
1693
1687
|
</li>
|
1694
1688
|
|
1695
|
-
<li class="covered" data-hits="11" data-linenumber="
|
1689
|
+
<li class="covered" data-hits="11" data-linenumber="108">
|
1696
1690
|
<span class="hits">11</span>
|
1697
1691
|
|
1698
1692
|
<code class="ruby"> options = BB::Hash.symbolize_keys(args)</code>
|
1699
1693
|
</li>
|
1700
1694
|
|
1701
|
-
<li class="never" data-hits="" data-linenumber="
|
1695
|
+
<li class="never" data-hits="" data-linenumber="109">
|
1702
1696
|
|
1703
1697
|
|
1704
1698
|
<code class="ruby"></code>
|
1705
1699
|
</li>
|
1706
1700
|
|
1707
|
-
<li class="covered" data-hits="11" data-linenumber="
|
1701
|
+
<li class="covered" data-hits="11" data-linenumber="110">
|
1708
1702
|
<span class="hits">11</span>
|
1709
1703
|
|
1710
1704
|
<code class="ruby"> precision ||= (options[:precision] || 3)</code>
|
1711
1705
|
</li>
|
1712
1706
|
|
1713
|
-
<li class="covered" data-hits="11" data-linenumber="
|
1707
|
+
<li class="covered" data-hits="11" data-linenumber="111">
|
1714
1708
|
<span class="hits">11</span>
|
1715
1709
|
|
1716
1710
|
<code class="ruby"> separator ||= (options[:separator] || '.')</code>
|
1717
1711
|
</li>
|
1718
1712
|
|
1719
|
-
<li class="covered" data-hits="11" data-linenumber="
|
1713
|
+
<li class="covered" data-hits="11" data-linenumber="112">
|
1720
1714
|
<span class="hits">11</span>
|
1721
1715
|
|
1722
1716
|
<code class="ruby"> delimiter ||= (options[:delimiter] || '')</code>
|
1723
1717
|
</li>
|
1724
1718
|
|
1725
|
-
<li class="never" data-hits="" data-linenumber="
|
1719
|
+
<li class="never" data-hits="" data-linenumber="113">
|
1726
1720
|
|
1727
1721
|
|
1728
1722
|
<code class="ruby"></code>
|
1729
1723
|
</li>
|
1730
1724
|
|
1731
|
-
<li class="covered" data-hits="11" data-linenumber="
|
1725
|
+
<li class="covered" data-hits="11" data-linenumber="114">
|
1732
1726
|
<span class="hits">11</span>
|
1733
1727
|
|
1734
1728
|
<code class="ruby"> begin</code>
|
1735
1729
|
</li>
|
1736
1730
|
|
1737
|
-
<li class="covered" data-hits="11" data-linenumber="
|
1731
|
+
<li class="covered" data-hits="11" data-linenumber="115">
|
1738
1732
|
<span class="hits">11</span>
|
1739
1733
|
|
1740
1734
|
<code class="ruby"> rounded_number = (Float(number) * (10 ** precision)).round.to_f / 10 ** precision</code>
|
1741
1735
|
</li>
|
1742
1736
|
|
1743
|
-
<li class="covered" data-hits="11" data-linenumber="
|
1737
|
+
<li class="covered" data-hits="11" data-linenumber="116">
|
1744
1738
|
<span class="hits">11</span>
|
1745
1739
|
|
1746
1740
|
<code class="ruby"> with_delimiter("%01.#{precision}f" % rounded_number,</code>
|
1747
1741
|
</li>
|
1748
1742
|
|
1749
|
-
<li class="never" data-hits="" data-linenumber="
|
1743
|
+
<li class="never" data-hits="" data-linenumber="117">
|
1750
1744
|
|
1751
1745
|
|
1752
1746
|
<code class="ruby"> :separator => separator,</code>
|
1753
1747
|
</li>
|
1754
1748
|
|
1755
|
-
<li class="never" data-hits="" data-linenumber="
|
1749
|
+
<li class="never" data-hits="" data-linenumber="118">
|
1756
1750
|
|
1757
1751
|
|
1758
1752
|
<code class="ruby"> :delimiter => delimiter)</code>
|
1759
1753
|
</li>
|
1760
1754
|
|
1761
|
-
<li class="never" data-hits="" data-linenumber="
|
1755
|
+
<li class="never" data-hits="" data-linenumber="119">
|
1762
1756
|
|
1763
1757
|
|
1764
1758
|
<code class="ruby"> rescue</code>
|
1765
1759
|
</li>
|
1766
1760
|
|
1767
|
-
<li class="missed" data-hits="0" data-linenumber="
|
1761
|
+
<li class="missed" data-hits="0" data-linenumber="120">
|
1768
1762
|
|
1769
1763
|
|
1770
1764
|
<code class="ruby"> number</code>
|
1771
1765
|
</li>
|
1772
1766
|
|
1773
|
-
<li class="never" data-hits="" data-linenumber="
|
1767
|
+
<li class="never" data-hits="" data-linenumber="121">
|
1774
1768
|
|
1775
1769
|
|
1776
1770
|
<code class="ruby"> end</code>
|
1777
1771
|
</li>
|
1778
1772
|
|
1779
|
-
<li class="never" data-hits="" data-linenumber="
|
1773
|
+
<li class="never" data-hits="" data-linenumber="122">
|
1780
1774
|
|
1781
1775
|
|
1782
1776
|
<code class="ruby"> end</code>
|
1783
1777
|
</li>
|
1784
1778
|
|
1785
|
-
<li class="never" data-hits="" data-linenumber="
|
1779
|
+
<li class="never" data-hits="" data-linenumber="123">
|
1786
1780
|
|
1787
1781
|
|
1788
1782
|
<code class="ruby"></code>
|
1789
1783
|
</li>
|
1790
1784
|
|
1791
|
-
<li class="never" data-hits="" data-linenumber="
|
1785
|
+
<li class="never" data-hits="" data-linenumber="124">
|
1792
1786
|
|
1793
1787
|
|
1794
1788
|
<code class="ruby"> ##</code>
|
1795
1789
|
</li>
|
1796
1790
|
|
1797
|
-
<li class="never" data-hits="" data-linenumber="
|
1791
|
+
<li class="never" data-hits="" data-linenumber="125">
|
1798
1792
|
|
1799
1793
|
|
1800
1794
|
<code class="ruby"> # Formats a +number+ with grouped thousands using +delimiter+ (e.g., 12,324). You can</code>
|
1801
1795
|
</li>
|
1802
1796
|
|
1803
|
-
<li class="never" data-hits="" data-linenumber="
|
1797
|
+
<li class="never" data-hits="" data-linenumber="126">
|
1804
1798
|
|
1805
1799
|
|
1806
1800
|
<code class="ruby"> # customize the format in the +options+ hash.</code>
|
1807
1801
|
</li>
|
1808
1802
|
|
1809
|
-
<li class="never" data-hits="" data-linenumber="
|
1803
|
+
<li class="never" data-hits="" data-linenumber="127">
|
1810
1804
|
|
1811
1805
|
|
1812
1806
|
<code class="ruby"> #</code>
|
1813
1807
|
</li>
|
1814
1808
|
|
1815
|
-
<li class="never" data-hits="" data-linenumber="
|
1809
|
+
<li class="never" data-hits="" data-linenumber="128">
|
1816
1810
|
|
1817
1811
|
|
1818
1812
|
<code class="ruby"> # @overload with_delimiter(number, options={})</code>
|
1819
1813
|
</li>
|
1820
1814
|
|
1821
|
-
<li class="never" data-hits="" data-linenumber="
|
1815
|
+
<li class="never" data-hits="" data-linenumber="129">
|
1822
1816
|
|
1823
1817
|
|
1824
1818
|
<code class="ruby"> # @param [Fixnum, Float] number</code>
|
1825
1819
|
</li>
|
1826
1820
|
|
1827
|
-
<li class="never" data-hits="" data-linenumber="
|
1821
|
+
<li class="never" data-hits="" data-linenumber="130">
|
1828
1822
|
|
1829
1823
|
|
1830
1824
|
<code class="ruby"> # Number value to format.</code>
|
1831
1825
|
</li>
|
1832
1826
|
|
1833
|
-
<li class="never" data-hits="" data-linenumber="
|
1827
|
+
<li class="never" data-hits="" data-linenumber="131">
|
1834
1828
|
|
1835
1829
|
|
1836
1830
|
<code class="ruby"> # @param [Hash] options</code>
|
1837
1831
|
</li>
|
1838
1832
|
|
1839
|
-
<li class="never" data-hits="" data-linenumber="
|
1833
|
+
<li class="never" data-hits="" data-linenumber="132">
|
1840
1834
|
|
1841
1835
|
|
1842
1836
|
<code class="ruby"> # Options for formatter.</code>
|
1843
1837
|
</li>
|
1844
1838
|
|
1845
|
-
<li class="never" data-hits="" data-linenumber="
|
1839
|
+
<li class="never" data-hits="" data-linenumber="133">
|
1846
1840
|
|
1847
1841
|
|
1848
1842
|
<code class="ruby"> # @option options [String] :delimiter (", ")</code>
|
1849
1843
|
</li>
|
1850
1844
|
|
1851
|
-
<li class="never" data-hits="" data-linenumber="
|
1845
|
+
<li class="never" data-hits="" data-linenumber="134">
|
1852
1846
|
|
1853
1847
|
|
1854
1848
|
<code class="ruby"> # Sets the thousands delimiter.</code>
|
1855
1849
|
</li>
|
1856
1850
|
|
1857
|
-
<li class="never" data-hits="" data-linenumber="
|
1851
|
+
<li class="never" data-hits="" data-linenumber="135">
|
1858
1852
|
|
1859
1853
|
|
1860
1854
|
<code class="ruby"> # @option options [String] :separator (".")</code>
|
1861
1855
|
</li>
|
1862
1856
|
|
1863
|
-
<li class="never" data-hits="" data-linenumber="
|
1857
|
+
<li class="never" data-hits="" data-linenumber="136">
|
1864
1858
|
|
1865
1859
|
|
1866
1860
|
<code class="ruby"> # Sets the separator between the units.</code>
|
1867
1861
|
</li>
|
1868
1862
|
|
1869
|
-
<li class="never" data-hits="" data-linenumber="
|
1863
|
+
<li class="never" data-hits="" data-linenumber="137">
|
1870
1864
|
|
1871
1865
|
|
1872
1866
|
<code class="ruby"> #</code>
|
1873
1867
|
</li>
|
1874
1868
|
|
1875
|
-
<li class="never" data-hits="" data-linenumber="
|
1869
|
+
<li class="never" data-hits="" data-linenumber="138">
|
1876
1870
|
|
1877
1871
|
|
1878
1872
|
<code class="ruby"> # @return [String] The formatted representation of the number.</code>
|
1879
1873
|
</li>
|
1880
1874
|
|
1881
|
-
<li class="never" data-hits="" data-linenumber="
|
1875
|
+
<li class="never" data-hits="" data-linenumber="139">
|
1882
1876
|
|
1883
1877
|
|
1884
1878
|
<code class="ruby"> #</code>
|
1885
1879
|
</li>
|
1886
1880
|
|
1887
|
-
<li class="never" data-hits="" data-linenumber="
|
1881
|
+
<li class="never" data-hits="" data-linenumber="140">
|
1888
1882
|
|
1889
1883
|
|
1890
1884
|
<code class="ruby"> # @example</code>
|
1891
1885
|
</li>
|
1892
1886
|
|
1893
|
-
<li class="never" data-hits="" data-linenumber="
|
1887
|
+
<li class="never" data-hits="" data-linenumber="141">
|
1894
1888
|
|
1895
1889
|
|
1896
1890
|
<code class="ruby"> # with_delimiter(12345678) # => 12,345,678</code>
|
1897
1891
|
</li>
|
1898
1892
|
|
1899
|
-
<li class="never" data-hits="" data-linenumber="
|
1893
|
+
<li class="never" data-hits="" data-linenumber="142">
|
1900
1894
|
|
1901
1895
|
|
1902
1896
|
<code class="ruby"> # with_delimiter(12345678.05) # => 12,345,678.05</code>
|
1903
1897
|
</li>
|
1904
1898
|
|
1905
|
-
<li class="never" data-hits="" data-linenumber="
|
1899
|
+
<li class="never" data-hits="" data-linenumber="143">
|
1906
1900
|
|
1907
1901
|
|
1908
1902
|
<code class="ruby"> # with_delimiter(12345678, :delimiter => ".") # => 12.345.678</code>
|
1909
1903
|
</li>
|
1910
1904
|
|
1911
|
-
<li class="never" data-hits="" data-linenumber="
|
1905
|
+
<li class="never" data-hits="" data-linenumber="144">
|
1912
1906
|
|
1913
1907
|
|
1914
1908
|
<code class="ruby"> # with_delimiter(12345678, :separator => ",") # => 12,345,678</code>
|
1915
1909
|
</li>
|
1916
1910
|
|
1917
|
-
<li class="never" data-hits="" data-linenumber="
|
1911
|
+
<li class="never" data-hits="" data-linenumber="145">
|
1918
1912
|
|
1919
1913
|
|
1920
1914
|
<code class="ruby"> # with_delimiter(98765432.98, :delimiter => " ", :separator => ",")</code>
|
1921
1915
|
</li>
|
1922
1916
|
|
1923
|
-
<li class="never" data-hits="" data-linenumber="
|
1917
|
+
<li class="never" data-hits="" data-linenumber="146">
|
1924
1918
|
|
1925
1919
|
|
1926
1920
|
<code class="ruby"> # # => 98 765 432,98</code>
|
1927
1921
|
</li>
|
1928
1922
|
|
1929
|
-
<li class="never" data-hits="" data-linenumber="
|
1923
|
+
<li class="never" data-hits="" data-linenumber="147">
|
1930
1924
|
|
1931
1925
|
|
1932
1926
|
<code class="ruby"> #</code>
|
1933
1927
|
</li>
|
1934
1928
|
|
1935
|
-
<li class="covered" data-hits="1" data-linenumber="
|
1929
|
+
<li class="covered" data-hits="1" data-linenumber="148">
|
1936
1930
|
<span class="hits">1</span>
|
1937
1931
|
|
1938
1932
|
<code class="ruby"> def with_delimiter(number, args)</code>
|
1939
1933
|
</li>
|
1940
1934
|
|
1941
|
-
<li class="covered" data-hits="12" data-linenumber="
|
1935
|
+
<li class="covered" data-hits="12" data-linenumber="149">
|
1942
1936
|
<span class="hits">12</span>
|
1943
1937
|
|
1944
1938
|
<code class="ruby"> options = BB::Hash.symbolize_keys(args)</code>
|
1945
1939
|
</li>
|
1946
1940
|
|
1947
|
-
<li class="never" data-hits="" data-linenumber="
|
1941
|
+
<li class="never" data-hits="" data-linenumber="150">
|
1948
1942
|
|
1949
1943
|
|
1950
1944
|
<code class="ruby"></code>
|
1951
1945
|
</li>
|
1952
1946
|
|
1953
|
-
<li class="covered" data-hits="12" data-linenumber="
|
1947
|
+
<li class="covered" data-hits="12" data-linenumber="151">
|
1954
1948
|
<span class="hits">12</span>
|
1955
1949
|
|
1956
1950
|
<code class="ruby"> delimiter ||= (options[:delimiter] || '.')</code>
|
1957
1951
|
</li>
|
1958
1952
|
|
1959
|
-
<li class="covered" data-hits="12" data-linenumber="
|
1953
|
+
<li class="covered" data-hits="12" data-linenumber="152">
|
1960
1954
|
<span class="hits">12</span>
|
1961
1955
|
|
1962
1956
|
<code class="ruby"> separator ||= (options[:separator] || ',')</code>
|
1963
1957
|
</li>
|
1964
1958
|
|
1965
|
-
<li class="never" data-hits="" data-linenumber="
|
1959
|
+
<li class="never" data-hits="" data-linenumber="153">
|
1966
1960
|
|
1967
1961
|
|
1968
1962
|
<code class="ruby"></code>
|
1969
1963
|
</li>
|
1970
1964
|
|
1971
|
-
<li class="covered" data-hits="12" data-linenumber="
|
1965
|
+
<li class="covered" data-hits="12" data-linenumber="154">
|
1972
1966
|
<span class="hits">12</span>
|
1973
1967
|
|
1974
1968
|
<code class="ruby"> begin</code>
|
1975
1969
|
</li>
|
1976
1970
|
|
1977
|
-
<li class="covered" data-hits="12" data-linenumber="
|
1971
|
+
<li class="covered" data-hits="12" data-linenumber="155">
|
1978
1972
|
<span class="hits">12</span>
|
1979
1973
|
|
1980
1974
|
<code class="ruby"> parts = number.to_s.split('.')</code>
|
1981
1975
|
</li>
|
1982
1976
|
|
1983
|
-
<li class="covered" data-hits="12" data-linenumber="
|
1977
|
+
<li class="covered" data-hits="12" data-linenumber="156">
|
1984
1978
|
<span class="hits">12</span>
|
1985
1979
|
|
1986
1980
|
<code class="ruby"> parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")</code>
|
1987
1981
|
</li>
|
1988
1982
|
|
1989
|
-
<li class="covered" data-hits="12" data-linenumber="
|
1983
|
+
<li class="covered" data-hits="12" data-linenumber="157">
|
1990
1984
|
<span class="hits">12</span>
|
1991
1985
|
|
1992
1986
|
<code class="ruby"> parts.join(separator)</code>
|
1993
1987
|
</li>
|
1994
1988
|
|
1995
|
-
<li class="never" data-hits="" data-linenumber="
|
1989
|
+
<li class="never" data-hits="" data-linenumber="158">
|
1996
1990
|
|
1997
1991
|
|
1998
1992
|
<code class="ruby"> rescue</code>
|
1999
1993
|
</li>
|
2000
1994
|
|
2001
|
-
<li class="missed" data-hits="0" data-linenumber="
|
1995
|
+
<li class="missed" data-hits="0" data-linenumber="159">
|
2002
1996
|
|
2003
1997
|
|
2004
1998
|
<code class="ruby"> number</code>
|
2005
1999
|
</li>
|
2006
2000
|
|
2007
|
-
<li class="never" data-hits="" data-linenumber="
|
2001
|
+
<li class="never" data-hits="" data-linenumber="160">
|
2008
2002
|
|
2009
2003
|
|
2010
2004
|
<code class="ruby"> end</code>
|
2011
2005
|
</li>
|
2012
2006
|
|
2013
|
-
<li class="never" data-hits="" data-linenumber="
|
2007
|
+
<li class="never" data-hits="" data-linenumber="161">
|
2014
2008
|
|
2015
2009
|
|
2016
2010
|
<code class="ruby"> end</code>
|
2017
2011
|
</li>
|
2018
2012
|
|
2019
|
-
<li class="never" data-hits="" data-linenumber="
|
2013
|
+
<li class="never" data-hits="" data-linenumber="162">
|
2020
2014
|
|
2021
2015
|
|
2022
2016
|
<code class="ruby"> end</code>
|
2023
2017
|
</li>
|
2024
2018
|
|
2025
|
-
<li class="never" data-hits="" data-linenumber="
|
2019
|
+
<li class="never" data-hits="" data-linenumber="163">
|
2026
2020
|
|
2027
2021
|
|
2028
2022
|
<code class="ruby"> end</code>
|
2029
2023
|
</li>
|
2030
2024
|
|
2031
|
-
<li class="never" data-hits="" data-linenumber="
|
2025
|
+
<li class="never" data-hits="" data-linenumber="164">
|
2032
2026
|
|
2033
2027
|
|
2034
2028
|
<code class="ruby">end</code>
|
2035
2029
|
</li>
|
2036
2030
|
|
2037
|
-
<li class="never" data-hits="" data-linenumber="
|
2031
|
+
<li class="never" data-hits="" data-linenumber="165">
|
2038
2032
|
|
2039
2033
|
|
2040
2034
|
<code class="ruby"></code>
|