epitools 0.5.81 → 0.5.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/epitools/core_ext/numbers.rb +17 -0
- data/spec/core_ext_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d8582a82f2b83be800a230a245509867e8d3030
|
|
4
|
+
data.tar.gz: a001aa5d42cb18dd30bdb3d702233182ae065477
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 85f076412d6027d1229094d1a7a20974b18ba3d0485ef84db9520ca7709298ae6d31807e3c1db516ceda008a1718ba3c7ab6264ff6d9d04d3fd977122b0a5b8e
|
|
7
|
+
data.tar.gz: 33abc6e8357cec5e8bbfe04f89400b868ab6d45908ab48ad08954dda5ca78ec29ab7dcae2c6baa1d4e5c1aa6ab22fe46503526ffe253593568b1355c85192770
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.5.
|
|
1
|
+
0.5.82
|
|
@@ -368,6 +368,23 @@ end
|
|
|
368
368
|
end
|
|
369
369
|
|
|
370
370
|
|
|
371
|
+
class Float
|
|
372
|
+
|
|
373
|
+
#
|
|
374
|
+
# Convert the float to a rounded percentage string (eg: "42%").
|
|
375
|
+
# Its argument lets you specify how many decimals to display
|
|
376
|
+
#
|
|
377
|
+
# eg:
|
|
378
|
+
# > 0.32786243.percent # => "33%"
|
|
379
|
+
# > 0.32786243.percent(2) # => "32.79%"
|
|
380
|
+
#
|
|
381
|
+
def percent(decimals=0)
|
|
382
|
+
"%0.#{decimals}f%" % (self * 100)
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
|
|
371
388
|
class Time
|
|
372
389
|
|
|
373
390
|
#
|
data/spec/core_ext_spec.rb
CHANGED
|
@@ -410,6 +410,14 @@ describe Float do
|
|
|
410
410
|
objects.each { |object| object.float?.should == expected_result }
|
|
411
411
|
end
|
|
412
412
|
end
|
|
413
|
+
|
|
414
|
+
it "percent" do
|
|
415
|
+
f = 0.716237
|
|
416
|
+
f.percent.should == "72%"
|
|
417
|
+
f.percent(2).should == "71.62%"
|
|
418
|
+
f.percent(3).should == "71.624%"
|
|
419
|
+
end
|
|
420
|
+
|
|
413
421
|
end
|
|
414
422
|
|
|
415
423
|
describe Number do
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: epitools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.82
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- epitron
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-12-
|
|
11
|
+
date: 2015-12-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|