farmoney 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 460f7c3b738e24f2ab4c72ffacc9409c7dd07fa3cb1966f7bfaac3a4c4c45f5e
4
- data.tar.gz: 86d040b258ca2b7c31190952e3c74b83d549030927e6a151d73cc8e62a817072
3
+ metadata.gz: e0264cc7c1b0eeb15b673ea24064809122f92b96fd67ca44b3b9159d6420b5f9
4
+ data.tar.gz: 53e360b3bb284f5293439980b78e7c3867642dfb55deaecf0a384f82554c2562
5
5
  SHA512:
6
- metadata.gz: 9f25fb0dc6e2fb1928cf53c0dd78a2f96be7469f23f86d471f121c515edc03ef4efd2a64fdadc52e4eb9f08ad84dba9716eef1711893f883e7b89f2493893d94
7
- data.tar.gz: 02c8cd4b8508bcb2de088017843c828bd8b2f01b94984bfb7b5423c15d13576d37abfea265f0f8e77c3dcee5ec2c3f981dade41562c9ff5d213c44a29136a75c
6
+ metadata.gz: 51254c97b5b27f187f98ffb72d823eb9bcfa8956d50bce67bf2284af24cb597e62bc19e51dbd96e7669dd34f25fd116a13a1b973680d25bdda53b9911907b650
7
+ data.tar.gz: 87662269314255b99bc2ed4037e1d4985448676e469e20b600cf79608998279d7aefd85cfa0b28d6cc8d1db5f73bbf8cd0a31cb666d09c4ea3a22612ca9f30fe
@@ -1,3 +1,4 @@
1
+ require "bigdecimal"
1
2
  require "farmoney/money"
2
3
  require "farmoney/vat"
3
4
  require "farmoney/version"
@@ -20,6 +20,14 @@ module Farmoney
20
20
  format("£%.1i.%.2i", pounds, pence)
21
21
  end
22
22
 
23
+ def attributes
24
+ instance_variables.each.with_object({}) do |attribute, hash|
25
+ hash[attribute_name(attribute)] = instance_variable_get(attribute)
26
+ end
27
+ end
28
+
29
+ alias to_hash attributes
30
+
23
31
  def +(other)
24
32
  Money.new(pence + other.pence)
25
33
  end
@@ -36,6 +44,11 @@ module Farmoney
36
44
  def *(other)
37
45
  Money.new(pence * other)
38
46
  end
47
+
48
+ private
49
+
50
+ def attribute_name(attribute)
51
+ attribute.to_s.sub("@", "").to_sym
52
+ end
39
53
  end
40
54
  end
41
-
@@ -1,3 +1,3 @@
1
1
  module Farmoney
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: farmoney
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Chipchase
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-12 00:00:00.000000000 Z
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler