gnucash 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/gnucash/value.rb +4 -4
- data/lib/gnucash/version.rb +1 -1
- data/spec/gnucash/value_spec.rb +18 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 900fd81bad3ba0b11854c9337bc222b535804b02
|
4
|
+
data.tar.gz: 5549a7746596aae5be8f4081a1b6ba322b2f98b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5bb85d5c99510c17af02d0b649f637a4c939eb90e2392bddeadc22926699c96a28d11fb7cba43a7114d29e4d38fb413bbfb082611ca2c70f6f9e6fb13f9bd4b
|
7
|
+
data.tar.gz: f0f3934018eb94ae3a989abdbb95c94aaeb3dd8f0a399e3fa85e8f26937184577d55f775b8a38a51334f845942f62ca32225041cbc651139e3db70d252c1b139
|
data/Gemfile.lock
CHANGED
data/lib/gnucash/value.rb
CHANGED
@@ -50,7 +50,7 @@ module Gnucash
|
|
50
50
|
lcm_div = @div.lcm(other.div)
|
51
51
|
Value.new((@val * (lcm_div / @div)) + (other.val * (lcm_div / other.div)), lcm_div)
|
52
52
|
elsif other.is_a?(Numeric)
|
53
|
-
|
53
|
+
to_f + other
|
54
54
|
else
|
55
55
|
raise "Unexpected argument"
|
56
56
|
end
|
@@ -66,7 +66,7 @@ module Gnucash
|
|
66
66
|
lcm_div = @div.lcm(other.div)
|
67
67
|
Value.new((@val * (lcm_div / @div)) - (other.val * (lcm_div / other.div)), lcm_div)
|
68
68
|
elsif other.is_a?(Numeric)
|
69
|
-
|
69
|
+
to_f - other
|
70
70
|
else
|
71
71
|
raise "Unexpected argument"
|
72
72
|
end
|
@@ -89,7 +89,7 @@ module Gnucash
|
|
89
89
|
other = other.to_f
|
90
90
|
end
|
91
91
|
if other.is_a?(Numeric)
|
92
|
-
|
92
|
+
to_f * other
|
93
93
|
else
|
94
94
|
raise "Unexpected argument (#{other.inspect})"
|
95
95
|
end
|
@@ -105,7 +105,7 @@ module Gnucash
|
|
105
105
|
other = other.to_f
|
106
106
|
end
|
107
107
|
if other.is_a?(Numeric)
|
108
|
-
|
108
|
+
to_f / other
|
109
109
|
else
|
110
110
|
raise "Unexpected argument (#{other.inspect})"
|
111
111
|
end
|
data/lib/gnucash/version.rb
CHANGED
data/spec/gnucash/value_spec.rb
CHANGED
@@ -34,7 +34,7 @@ module Gnucash
|
|
34
34
|
a = Value.new("1234/100")
|
35
35
|
b = 15
|
36
36
|
c = a + b
|
37
|
-
expect(c).to eq 27.34
|
37
|
+
expect(c.round(2)).to eq 27.34
|
38
38
|
end
|
39
39
|
|
40
40
|
it "allows subtracting two value objects" do
|
@@ -48,7 +48,7 @@ module Gnucash
|
|
48
48
|
a = Value.new("890/100")
|
49
49
|
b = 7.8
|
50
50
|
c = a - b
|
51
|
-
expect(c).to eq 1.1
|
51
|
+
expect(c.round(2)).to eq 1.1
|
52
52
|
end
|
53
53
|
|
54
54
|
it "allows negating a Value object" do
|
@@ -61,14 +61,28 @@ module Gnucash
|
|
61
61
|
a = Value.new("100/100")
|
62
62
|
b = 12
|
63
63
|
c = a * b
|
64
|
-
expect(c).to eq 12.00
|
64
|
+
expect(c.round(2)).to eq 12.00
|
65
|
+
end
|
66
|
+
|
67
|
+
it "allows multiplying a Value by a Value" do
|
68
|
+
a = Value.new("100/100")
|
69
|
+
b = Value.new(1200)
|
70
|
+
c = a * b
|
71
|
+
expect(c.round(2)).to eq 12.00
|
65
72
|
end
|
66
73
|
|
67
74
|
it "allows dividing a Value by a Numeric" do
|
68
75
|
a = Value.new("150000/100")
|
69
76
|
b = 150
|
70
77
|
c = a / b
|
71
|
-
expect(c).to eq 10.0
|
78
|
+
expect(c.round(2)).to eq 10.0
|
79
|
+
end
|
80
|
+
|
81
|
+
it "allows dividing a Value by a Value" do
|
82
|
+
a = Value.new("150000/100")
|
83
|
+
b = Value.new(15000)
|
84
|
+
c = a / b
|
85
|
+
expect(c.round(2)).to eq 10.0
|
72
86
|
end
|
73
87
|
|
74
88
|
it "formats the number with two decimal places" do
|