percentage 2.1.1 → 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: da6d1c6c5ff20dee1500808d27aa029754cf4ac8771a9750363de4c701c37a15
4
- data.tar.gz: f5021e0a31e03ccdf52108e7ba5e0c743567afbf0ff4716449e60c76d788a0b2
3
+ metadata.gz: 017b498f1847df3570b1176c1047a0a3ab2fa394c24befbd2abdc8f4cb7e5f5e
4
+ data.tar.gz: cee72ecd3ab177c51d7784b2d596b2ec1abc4eafefaf1569a9adf32d09785bac
5
5
  SHA512:
6
- metadata.gz: 97fc4161adefd0e64646970976af477a71830534c399a5d9a7d89022a61ba065a57b9698af64cfdc8413aeb6c68cf860aa2d79931811dcf830b21f23b3888e0d
7
- data.tar.gz: a526ad11816cb946dacf2ee16973485e236d2e826d5811113ada545b3a8b73db81607f26cbdd629474dc637525cd35901a71c383c2e62ba0956fefb070bece48
6
+ metadata.gz: 12621156aca237f0d6dc30d341103e4cd61caf9b2282e26aa9069651e4f6d40c71dc5be575b5a62a060bb896fb81f990f53e59c5290bb9425d124fdb583f57b6
7
+ data.tar.gz: a6cc6d0c86841a1c2fc203e5a6fd66849e0dbb9484368457d54edf4e012b1dececf26f66a1846394f016c6222cb1d510b88f4cf2536966c00b90f58335eecddc
data/CHANGES.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 2.2.0
2
+
3
+ * Added Rational#to_percentage
4
+
5
+ * Added Rational#percent_of
6
+
7
+ * Added Rational#as_percentage_of
8
+
1
9
  # 2.1.1
2
10
 
3
11
  * Added bigdecimal gem dependency (thanks @orien)
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.1'
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']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percentage
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
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-03-06 00:00:00.000000000 Z
11
+ date: 2024-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  requirements: []
63
- rubygems_version: 3.5.3
63
+ rubygems_version: 3.5.11
64
64
  signing_key:
65
65
  specification_version: 4
66
66
  summary: See description