paragoz 2.2.5 → 2.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paragoz.rb +19 -16
- data/lib/paragoz/version.rb +1 -1
- data/paragoz-2.2.5.gem +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 629edb93d13bfb51bdb948a663075e7740331744
|
4
|
+
data.tar.gz: d7e930b81103001c07f512ca7a71f251a1464d2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c85535c5215f66e65e1f3f8b3528d4efed3ae907db66efeb43e963da0d2fa2b0e448c274865dae40f29df744b55591badde12c0028193ce1f6a6e1dc7ff072c
|
7
|
+
data.tar.gz: 165ce1d8b513619b109bccef4157c2400e106786a10c5996b7e30669d81994c8d2e83d1da7eaa25078d45c866cbc8658743080c3ce0762396b5e627161e072f2
|
data/lib/paragoz.rb
CHANGED
@@ -16,21 +16,21 @@ module Paragoz
|
|
16
16
|
|
17
17
|
def initialize(code, amount, data, date)
|
18
18
|
@data = data || parse_data(take_response(code.upcase, date))
|
19
|
-
@
|
20
|
-
@base
|
21
|
-
@date
|
22
|
-
@rates
|
23
|
-
@costs
|
24
|
-
@amount
|
19
|
+
@time_arr = @data["date"].split('-').map(&:to_i)
|
20
|
+
@base = @data["base"]
|
21
|
+
@date = @time_arr.is_a?(Array) ? Time.new(*@time_array) : Time.now
|
22
|
+
@rates = @data["rates"]
|
23
|
+
@costs = cost_of_other_currencies
|
24
|
+
@amount = amount
|
25
25
|
|
26
26
|
@@currencies_defined += 1
|
27
27
|
end
|
28
28
|
|
29
29
|
def amount=(value)
|
30
|
-
if value.
|
31
|
-
@amount = value.
|
30
|
+
if value.to_f > 0.0
|
31
|
+
@amount = value.to_f
|
32
32
|
else
|
33
|
-
puts "ERROR! Amount must be a Number and greater than 0."
|
33
|
+
puts "ERROR! Amount must be a Number and greater than 0.0"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -62,19 +62,21 @@ module Paragoz
|
|
62
62
|
|
63
63
|
def calculate_cost(currency_code ,calculation_amount = 1.0, info = false)
|
64
64
|
cost = 0.0
|
65
|
-
if amount.
|
65
|
+
if amount.to_f > 0.0 && CURRENCY_CODES.include?(currency_code.upcase)
|
66
66
|
cost = self.costs[currency_code.upcase] * calculation_amount || self.amount
|
67
67
|
puts "You need #{cost} #{@base} to buy #{amount} #{currency_code}" if info
|
68
68
|
cost
|
69
69
|
else
|
70
|
-
puts "ERROR!
|
70
|
+
puts "ERROR! PARAMETERS ARE currency_code(string) & calculate_amount(float)"
|
71
|
+
puts "3rd parameter is boolean for extra info"
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
74
|
-
def currency_to_currency(
|
75
|
-
if self.base !=
|
76
|
-
exchange = self.amount * self.rates[
|
77
|
-
printf("%.2f %s equals to %.4f %s \n",
|
75
|
+
def currency_to_currency(other_currency, info = false)
|
76
|
+
if self.base != other_currency.base
|
77
|
+
exchange = self.amount * self.rates[other_currency.base]
|
78
|
+
printf("%.2f %s equals to %.4f %s \n",
|
79
|
+
@amount, @base, exchange, other_currency.base) if info
|
78
80
|
exchange
|
79
81
|
else
|
80
82
|
puts "Error! Trying to conver same currency object."
|
@@ -84,7 +86,8 @@ module Paragoz
|
|
84
86
|
|
85
87
|
def exchange_to(currency_code, exchance_amount = nil, info = false)
|
86
88
|
exchange = @rates[currency_code.upcase] * (exchance_amount || self.amount)
|
87
|
-
printf("%.2f %s equals to %.4f",
|
89
|
+
printf("%.2f %s equals to %.4f",
|
90
|
+
amount, @base, exchange) if info
|
88
91
|
exchange
|
89
92
|
end
|
90
93
|
|
data/lib/paragoz/version.rb
CHANGED
data/paragoz-2.2.5.gem
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paragoz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gökhan Çağlar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- bin/setup
|
94
94
|
- lib/paragoz.rb
|
95
95
|
- lib/paragoz/version.rb
|
96
|
+
- paragoz-2.2.5.gem
|
96
97
|
- paragoz.gemspec
|
97
98
|
homepage: https://github.com/cptangry/paragoz
|
98
99
|
licenses:
|