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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1793bbd7b6b1b928acb530c6a5957e40e0bbe7920ec020506d589122439e8c3
4
- data.tar.gz: af09f58d73222e07289cef4cf817abcf62088628ecfa0f16f020de6bc527ce63
3
+ metadata.gz: 43f0235535c16fe8fb93d6dc2ee62402c23b0c6dc1ba71bfe06fb06ca14e2ef9
4
+ data.tar.gz: 7d5575f636e5a828967a95c92d1ef1546c806de01b4567a93c96736d7f4c20af
5
5
  SHA512:
6
- metadata.gz: 50a97d683053b1a2f5ec8d754b10bfc2805b573ba03c8656761b990428626adb9e0b42bf8d5b15818c3c1ed76b28ac369921f02373838a9eeecec873d08023e2
7
- data.tar.gz: 3774c22b8c4ef48405b873305c5254fee8d8397947543481ca3bc0de2710d20dd3fcaf92cef6b726c2a136e0a5c2c6a2a3e6f939866881dc67e805aafa18839f
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
- def *(other)
50
- case other
51
- when Money
52
- other * @value
53
- when Numeric
54
- Util.convert_to_money(other) * @value
55
- when VATPercentage
56
- raise TypeError.new "Can't multiply a VATPercentage by another VATPercentage"
57
- else
58
- if other.respond_to?(:coerce)
59
- a,b = other.coerce(self)
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
- raise TypeError.new "Can't multiply #{other.class} by VATPercentage"
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
@@ -1,3 +1,3 @@
1
1
  module Vatcalc
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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:
Binary file