more_core_extensions 3.5.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +1 -0
- data/lib/more_core_extensions/core_ext/string/decimal_suffix.rb +18 -5
- data/lib/more_core_extensions/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 605b41f75443bf69e235fccd80b9b94c48cbf44f95e5205ea540d5b36a84a75d
|
4
|
+
data.tar.gz: 8cd816257ef3a0e564960273a65415173c207a962fe0aa8e681b4b83565edc12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6300d6be1bc10872dbc485160f1c51a2b388fa687e160944712d27d2ef12f41a98e122697855ff8fca3ea87a9f2f2b3d4cfacc9e83286d0f3559cf4375a56a9
|
7
|
+
data.tar.gz: 76554a13bfcce20c1a7b361185f7215c552e7306b747168b8d3a21ae19d0908b6d02d30c91f127f1823f3bee5d5a5143721972e3d3252ece8f6ccd5e5ebe284e
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
+
## [3.6.0] - 2018-03-01
|
8
|
+
### Added
|
9
|
+
- Added String#decimal_si_to_big_decimal [[#59](https://github.com/ManageIQ/more_core_extensions/pull/59)]
|
10
|
+
|
7
11
|
## [3.5.0] - 2017-12-29
|
8
12
|
### Added
|
9
13
|
- Added String#hostname? [[#58](https://github.com/ManageIQ/more_core_extensions/pull/58)]
|
@@ -57,7 +61,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
57
61
|
- Upgraded to RSpec 3 [[#16](https://github.com/ManageIQ/more_core_extensions/pull/16)]
|
58
62
|
- Added the Change Log!
|
59
63
|
|
60
|
-
[Unreleased]: https://github.com/ManageIQ/more_core_extensions/compare/v3.
|
64
|
+
[Unreleased]: https://github.com/ManageIQ/more_core_extensions/compare/v3.6.0...HEAD
|
65
|
+
[3.6.0]: https://github.com/ManageIQ/more_core_extensions/compare/v3.5.0...v3.6.0
|
61
66
|
[3.5.0]: https://github.com/ManageIQ/more_core_extensions/compare/v3.4.0...v3.5.0
|
62
67
|
[3.4.0]: https://github.com/ManageIQ/more_core_extensions/compare/v3.3.0...v3.4.0
|
63
68
|
[3.3.0]: https://github.com/ManageIQ/more_core_extensions/compare/v3.2.0...v3.3.0
|
data/README.md
CHANGED
@@ -88,6 +88,7 @@ MoreCoreExtensions are a set of core extensions beyond those provided by ActiveS
|
|
88
88
|
#### String
|
89
89
|
|
90
90
|
* core_ext/string/decimal_suffix.rb
|
91
|
+
* `#decimal_si_to_big_decimal` - Returns a BigDecimal based on the number and suffix given
|
91
92
|
* `#decimal_si_to_f` - Returns a Float based on the number and suffix given
|
92
93
|
* core_ext/string/formats.rb
|
93
94
|
* `#email?` - Returns whether or not the String is an= valid email
|
@@ -1,14 +1,27 @@
|
|
1
|
+
require 'bigdecimal'
|
2
|
+
|
1
3
|
module MoreCoreExtensions
|
2
4
|
module DecimalSI
|
3
|
-
DECIMAL_SUFFIXES = {"d" =>
|
4
|
-
"a" =>
|
5
|
-
"E" =>
|
5
|
+
DECIMAL_SUFFIXES = {"d" => "e-1", "c" => "e-2", "m" => "e-3", "μ" => "e-6", "n" => "e-9", "p" => "e-12", "f" => "e-15",
|
6
|
+
"a" => "e-18", "h" => "e2", "k" => "e3", "M" => "e6", "G" => "e9", "T" => "e12", "P" => "e15",
|
7
|
+
"E" => "e18"}.freeze
|
8
|
+
|
6
9
|
def decimal_si_to_f
|
10
|
+
Float(decimal_si_to_scientific_notation)
|
11
|
+
end
|
12
|
+
|
13
|
+
def decimal_si_to_big_decimal
|
14
|
+
BigDecimal(decimal_si_to_scientific_notation)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def decimal_si_to_scientific_notation
|
7
20
|
multiplier = DECIMAL_SUFFIXES[self[-1]]
|
8
21
|
if multiplier
|
9
|
-
|
22
|
+
"#{self[0..-2]}#{multiplier}"
|
10
23
|
else
|
11
|
-
|
24
|
+
self
|
12
25
|
end
|
13
26
|
end
|
14
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: more_core_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Frey
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
188
|
version: '0'
|
189
189
|
requirements: []
|
190
190
|
rubyforge_project:
|
191
|
-
rubygems_version: 2.7.
|
191
|
+
rubygems_version: 2.7.6
|
192
192
|
signing_key:
|
193
193
|
specification_version: 4
|
194
194
|
summary: MoreCoreExtensions are a set of core extensions beyond those provided by
|