active_object 4.0.6 → 4.0.7
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/README.md +9 -0
- data/lib/active_object/numeric.rb +5 -0
- data/lib/active_object/version.rb +1 -1
- 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: 24ffb9180e5cc9d8cb5d113917fd0dfbb9df662b
|
|
4
|
+
data.tar.gz: b51ad3733a1033e3572b2e8885fe580d6e7196bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e2c7cf4d9c1ac6f77ef2d1d4a5b6b03a6a7531135709513d835373104f137a4bb9422ba828cf8b185fba932c3448ff9423c97090f6a49234e186c822958e5f1
|
|
7
|
+
data.tar.gz: a98cbeceb546c2c4d0dde6a742fdf4f21b7279a9e41df8d7ff3fb06b61e54ceedd6f02e97933df0c524e379e47f7ee816b02017cd4e909009e799d63976234e8
|
data/README.md
CHANGED
|
@@ -1039,6 +1039,15 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
|
1039
1039
|
3.pad_precision(pad_number: 1) #=> '3.11'
|
|
1040
1040
|
```
|
|
1041
1041
|
|
|
1042
|
+
**Percentage Of:**
|
|
1043
|
+
`percentage_of` returns the percentage of a number in relation to another number.
|
|
1044
|
+
|
|
1045
|
+
```ruby
|
|
1046
|
+
0.percentage_of(4) #=> 0
|
|
1047
|
+
2.percentage_of(0) #=> 0
|
|
1048
|
+
2.percentage_of(4) #=> 50.0
|
|
1049
|
+
```
|
|
1050
|
+
|
|
1042
1051
|
**Petabytes in Bytes:**
|
|
1043
1052
|
`petabyte_in_bytes` and `pegabytes_in_bytes` returns the amount of bytes in n petabytes.
|
|
1044
1053
|
|
|
@@ -364,6 +364,11 @@ module ActiveObject::Numeric
|
|
|
364
364
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
365
365
|
# rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity
|
|
366
366
|
|
|
367
|
+
def percentage_of(number)
|
|
368
|
+
return 0 if zero? || number.zero?
|
|
369
|
+
(to_f / number.to_f) * 100.0
|
|
370
|
+
end
|
|
371
|
+
|
|
367
372
|
def petabytes_in_bytes
|
|
368
373
|
self * PETABYTE
|
|
369
374
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_object
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.
|
|
4
|
+
version: 4.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Juan Gomez
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-05-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: dry-configurable
|