percentage 2.1.0 → 2.2.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: 21374fb1c476c85b4a4380ee15c3366aae81897a381c78eecfe4c439f4f333ab
4
- data.tar.gz: f7be43bf545ffa5982a22a3da8ecd2692f114335a88be8090190b297d178b298
3
+ metadata.gz: 017b498f1847df3570b1176c1047a0a3ab2fa394c24befbd2abdc8f4cb7e5f5e
4
+ data.tar.gz: cee72ecd3ab177c51d7784b2d596b2ec1abc4eafefaf1569a9adf32d09785bac
5
5
  SHA512:
6
- metadata.gz: 2305a119de4fb3e426a20ca722cb3dcd14c46039d24e5b8c16328e74cbe43514c673fa20c83fb9d8f6d62d909e518e545f6a33be46a3ecc11ab6ffe3408b31f4
7
- data.tar.gz: 6ac6258c6234e35a32b747f1317b725e84c3fdee226248b076d55fab34e4b2d43a54333de958eb6750640de3ae815a2a1657cbe279354f615dc3e1832f6ddec2
6
+ metadata.gz: 12621156aca237f0d6dc30d341103e4cd61caf9b2282e26aa9069651e4f6d40c71dc5be575b5a62a060bb896fb81f990f53e59c5290bb9425d124fdb583f57b6
7
+ data.tar.gz: a6cc6d0c86841a1c2fc203e5a6fd66849e0dbb9484368457d54edf4e012b1dececf26f66a1846394f016c6222cb1d510b88f4cf2536966c00b90f58335eecddc
data/CHANGES.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 2.2.0
2
+
3
+ * Added Rational#to_percentage
4
+
5
+ * Added Rational#percent_of
6
+
7
+ * Added Rational#as_percentage_of
8
+
9
+ # 2.1.1
10
+
11
+ * Added bigdecimal gem dependency (thanks @orien)
12
+
1
13
  # 2.1.0
2
14
 
3
15
  * Added Percentage#-@
data/lib/percentage.rb CHANGED
@@ -142,6 +142,20 @@ def Percentage.change(a, b)
142
142
  Percentage.new((b - a).to_r / a) unless a.zero?
143
143
  end
144
144
 
145
+ class Rational
146
+ def to_percentage
147
+ Percentage(self)
148
+ end
149
+
150
+ def percent_of(n)
151
+ n * Percentage(self)
152
+ end
153
+
154
+ def as_percentage_of(n)
155
+ Percentage.new(self / n)
156
+ end
157
+ end
158
+
145
159
  class BigDecimal
146
160
  def to_percentage
147
161
  Percentage(self)
data/percentage.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'percentage'
3
- s.version = '2.1.0'
3
+ s.version = '2.2.0'
4
4
  s.license = 'LGPL-3.0'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ['Tim Craft']
@@ -17,4 +17,5 @@ Gem::Specification.new do |s|
17
17
  'bug_tracker_uri' => 'https://github.com/readysteady/percentage/issues',
18
18
  'changelog_uri' => 'https://github.com/readysteady/percentage/blob/main/CHANGES.md'
19
19
  }
20
+ s.add_runtime_dependency 'bigdecimal'
20
21
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percentage
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Craft
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-11 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2024-10-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bigdecimal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Ruby gem for working with percentages
14
28
  email:
15
29
  - mail@timcraft.com
@@ -46,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  requirements: []
49
- rubygems_version: 3.4.10
63
+ rubygems_version: 3.5.11
50
64
  signing_key:
51
65
  specification_version: 4
52
66
  summary: See description