moneytest 0.1.1 → 0.1.2
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/lib/arithmetic/arithmetic.rb +17 -4
- data/lib/moneytest/version.rb +1 -1
- data/lib/moneytest.rb +4 -12
- metadata +2 -3
- data/lib/convert/convert.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8ca2ebc07b084455aa20b588a1347ac8ce5cb4e
|
4
|
+
data.tar.gz: 38cdd151c5a5f67777f902077df4f28314f87186
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc1db32747fe4548b36e5fca36f6fb993bb204ead27adb26422360ee1d7376abde6881572e2c195a5afd534efecf1bf63b2c1141c7ad9226eea6c55562507163
|
7
|
+
data.tar.gz: 95fc4bd402a80e7a692c6789fb82dc43259b1d3e1f1fe70c8e188b66a93d21aa7f5e48862cb55fd22f1f8ba231fb771861ac873fee2c85576d84ab811fd7bcf5
|
@@ -1,15 +1,28 @@
|
|
1
|
-
module
|
1
|
+
module Calculate
|
2
|
+
|
3
|
+
#faltó algo de manejo de errores
|
2
4
|
|
3
5
|
def value_exist(value)
|
4
|
-
value.respond_to?(:to_i) ? value : value.amount
|
6
|
+
(value.respond_to?(:to_i) ? value : value.amount)
|
7
|
+
end
|
8
|
+
|
9
|
+
def conv_euro(value)
|
10
|
+
case value.currency
|
11
|
+
when 'EUR'
|
12
|
+
value * 1
|
13
|
+
when 'USD'
|
14
|
+
value * 1.1
|
15
|
+
when 'Bitcoin'
|
16
|
+
value * 0.0047
|
17
|
+
end
|
5
18
|
end
|
6
19
|
|
7
20
|
def + (value)
|
8
|
-
|
21
|
+
@amount + conv_euro(value)
|
9
22
|
end
|
10
23
|
|
11
24
|
def - (value)
|
12
|
-
|
25
|
+
@amount - conv_euro(value)
|
13
26
|
end
|
14
27
|
|
15
28
|
def * (value)
|
data/lib/moneytest/version.rb
CHANGED
data/lib/moneytest.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
require_relative './arithmetic/arithmetic'
|
2
|
+
|
1
3
|
class Money
|
2
4
|
attr_accessor :amount, :currency
|
5
|
+
include Calculate
|
3
6
|
|
4
7
|
#################### validación y configuración
|
5
8
|
class << self
|
@@ -47,15 +50,4 @@ class Money
|
|
47
50
|
end
|
48
51
|
|
49
52
|
require_relative './configuration/configuration'
|
50
|
-
require_relative './error/handle_error'
|
51
|
-
|
52
|
-
# m1 = Money.new(100000, 'EUR')
|
53
|
-
# m2 = m1.convert('EUR')
|
54
|
-
# m3 = m1.convert('USD')
|
55
|
-
# m4 = m1.convert('Bitcoin')
|
56
|
-
# p m1.amount
|
57
|
-
# p m1.currency
|
58
|
-
# puts m1.inspect
|
59
|
-
# puts m2.inspect
|
60
|
-
# puts m3.inspect
|
61
|
-
# puts m4.inspect
|
53
|
+
require_relative './error/handle_error'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moneytest
|
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
|
- t00l
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,7 +71,6 @@ files:
|
|
71
71
|
- bin/setup
|
72
72
|
- lib/arithmetic/arithmetic.rb
|
73
73
|
- lib/configuration/configuration.rb
|
74
|
-
- lib/convert/convert.rb
|
75
74
|
- lib/error/handle_error.rb
|
76
75
|
- lib/moneytest.rb
|
77
76
|
- lib/moneytest/version.rb
|
data/lib/convert/convert.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module ConvertArit
|
2
|
-
|
3
|
-
class Convert
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(currency)
|
7
|
-
@currency = currency
|
8
|
-
end
|
9
|
-
|
10
|
-
def convert_to(currency)
|
11
|
-
case @currency
|
12
|
-
when "EUR"
|
13
|
-
@amount * 1.11 unless @type == "EUR"
|
14
|
-
when "Bitcoin"
|
15
|
-
@amount * 0.0047 unless @type == "Bitcoin"
|
16
|
-
when "USD"
|
17
|
-
@amount * 1.11 unless @type == "USD"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|