vatcalc 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vatcalc/vat_percentage.rb +19 -13
- data/lib/vatcalc/version.rb +1 -1
- metadata +1 -2
- data/vatcalc-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43f0235535c16fe8fb93d6dc2ee62402c23b0c6dc1ba71bfe06fb06ca14e2ef9
|
4
|
+
data.tar.gz: 7d5575f636e5a828967a95c92d1ef1546c806de01b4567a93c96736d7f4c20af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94a22456d4308e6354016d4e6b5770d3e9505392aa4f8df47d76b91af1dc06a1e1bd0466632b9451a1c383c7f60dccda01db9f3c873185aedd96337508ca42d0
|
7
|
+
data.tar.gz: 86a330db0a1d9d4f3da11679c05e05ab07c7f78078d0a694cace6579c580b13ad95bd2943459ce6b8d7b01838e0b5ec417b39018b9ab86e02ef09e705a39bc61
|
@@ -46,22 +46,28 @@ module Vatcalc
|
|
46
46
|
#@return [Money]
|
47
47
|
#@example
|
48
48
|
# => 10.00 * VATPercentage.new(19) #=> #<Money fractional:1190 currency:EUR>
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
a
|
60
|
-
a * b
|
49
|
+
[:/,:*].each do |m_name|
|
50
|
+
|
51
|
+
define_method(m_name) do |other|
|
52
|
+
|
53
|
+
case other
|
54
|
+
when Money
|
55
|
+
other.send(m_name,@value)
|
56
|
+
when Numeric
|
57
|
+
Util.convert_to_money(other).send(m_name,@value)
|
58
|
+
when VATPercentage
|
59
|
+
raise TypeError.new "Can't '#{m_name}' a VATPercentage by another VATPercentage"
|
61
60
|
else
|
62
|
-
|
61
|
+
if other.respond_to?(:coerce)
|
62
|
+
a,b = other.coerce(self)
|
63
|
+
a * b
|
64
|
+
else
|
65
|
+
raise TypeError.new "Can't '#{m_name}' #{other.class} by VATPercentage"
|
66
|
+
end
|
63
67
|
end
|
64
68
|
end
|
69
|
+
|
70
|
+
|
65
71
|
end
|
66
72
|
|
67
73
|
#@see https://www.mutuallyhuman.com/blog/2011/01/25/class-coercion-in-ruby
|
data/lib/vatcalc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vatcalc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Geduhn
|
@@ -106,7 +106,6 @@ files:
|
|
106
106
|
- lib/vatcalc/util.rb
|
107
107
|
- lib/vatcalc/vat_percentage.rb
|
108
108
|
- lib/vatcalc/version.rb
|
109
|
-
- vatcalc-0.1.0.gem
|
110
109
|
- vatcalc.gemspec
|
111
110
|
homepage: https://github.com/cgeduhn/vatcalc
|
112
111
|
licenses:
|
data/vatcalc-0.1.0.gem
DELETED
Binary file
|