gobl 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gobl/num/amount.rb +4 -5
- data/lib/gobl/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: 5d76cccae7dcefa86ad6553de26fdccdcf1070c86b94397b2afd6fce95973c5d
|
4
|
+
data.tar.gz: b08932429a3dceda76e61fad765e221126542b105b5141cfcac2bbab7df9d9fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 343e9b78a8c5d9e41614345310358b12b64360a2d6da81b52d5e0e03a4f819f045c0caa79772a02a285f6a62f991ff5804298eeaf6e0fe559a56d25c40a2cf01
|
7
|
+
data.tar.gz: d623de76e1c087bc6e391c43e5501ac74a593dadd0e3548ad1649b4955130589164538da7d3454d875f9a19bbc029e73e63cc47c7b5304eb51e0e9d254e8f091
|
data/lib/gobl/num/amount.rb
CHANGED
@@ -50,10 +50,9 @@ module GOBL
|
|
50
50
|
raise 'exponent too high' if exp > 100
|
51
51
|
|
52
52
|
p = 10**exp
|
53
|
-
v1 = value
|
54
|
-
|
55
|
-
|
56
|
-
format('%d.%0*d', v1, exp, v2)
|
53
|
+
v1, v2 = value.abs.divmod(p)
|
54
|
+
sign = value.negative? ? '-' : ''
|
55
|
+
format('%s%d.%0*d', sign, v1, exp, v2)
|
57
56
|
end
|
58
57
|
|
59
58
|
# Rescales each {Amount} in the pair ensuring both have the same exponent
|
@@ -208,7 +207,7 @@ module GOBL
|
|
208
207
|
v2 = x[1].to_i
|
209
208
|
e = x[1].length
|
210
209
|
v *= 10**e
|
211
|
-
v += v2
|
210
|
+
v += x[0].match?(/^-/) ? -v2 : v2
|
212
211
|
end
|
213
212
|
|
214
213
|
@value = v
|
data/lib/gobl/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gobl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Lilue
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-11-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
- !ruby/object:Gem::Version
|
195
195
|
version: 3.1.4
|
196
196
|
requirements: []
|
197
|
-
rubygems_version: 3.
|
197
|
+
rubygems_version: 3.3.7
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: Minimalist ruby version of the GOBL library
|