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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9fbc683524ab095292135f1e72a3821081619dacd00c22f288cb0be196805fcf
4
- data.tar.gz: d3ecf6bf8139048d076dcdde8cbb0131de4e32b16a0639546e8ed6c973f05b69
3
+ metadata.gz: 605b41f75443bf69e235fccd80b9b94c48cbf44f95e5205ea540d5b36a84a75d
4
+ data.tar.gz: 8cd816257ef3a0e564960273a65415173c207a962fe0aa8e681b4b83565edc12
5
5
  SHA512:
6
- metadata.gz: 4d52dd55d311849be201414a061eb3950c7976ca69118d941238680c3e5162e9a8aaf8a292ddc17dd5d2681fd0ae5fc8e575485c5f91e2f8ae0527683d79524d
7
- data.tar.gz: 175c56d081ec129ada8b131d135a880b680301eb50f96fde6f3b804e52587bc42219ba607cc1b1ffd963f7a88c22aa38b7def00aee8fa1e207c1761bb029be5d
6
+ metadata.gz: a6300d6be1bc10872dbc485160f1c51a2b388fa687e160944712d27d2ef12f41a98e122697855ff8fca3ea87a9f2f2b3d4cfacc9e83286d0f3559cf4375a56a9
7
+ data.tar.gz: 76554a13bfcce20c1a7b361185f7215c552e7306b747168b8d3a21ae19d0908b6d02d30c91f127f1823f3bee5d5a5143721972e3d3252ece8f6ccd5e5ebe284e
@@ -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.5.0...HEAD
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" => 1e-1, "c" => 1e-2, "m" => 1e-3, "μ" => 1e-6, "n" => 1e-9, "p" => 1e-12, "f" => 1e-15,
4
- "a" => 1e-18, "h" => 1e2, "k" => 1e3, "M" => 1e6, "G" => 1e9, "T" => 1e12, "P" => 1e15,
5
- "E" => 1e18}.freeze
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
- Float(self[0..-2]) * multiplier
22
+ "#{self[0..-2]}#{multiplier}"
10
23
  else
11
- Float(self)
24
+ self
12
25
  end
13
26
  end
14
27
  end
@@ -1,3 +1,3 @@
1
1
  module MoreCoreExtensions
2
- VERSION = "3.5.0".freeze
2
+ VERSION = "3.6.0".freeze
3
3
  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.5.0
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: 2017-12-29 00:00:00.000000000 Z
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.2
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