fxpotato 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fxpotato/cli.rb +5 -1
- data/lib/fxpotato/version.rb +1 -1
- data/lib/fxpotato.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71ac33c867e477ce35b75bf41d83216b9c421d41
|
4
|
+
data.tar.gz: 22dd4e3fa9df5a819d45b5faa316cfc2852536b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4259e6edd1926b50ce1d0c89688cd9e53a4b34aabfab1c60452a1742decb6dd3a284e3e06d0baea78a10fb0feaafaf2c62e4a71f645b613613ad8dcbb24ad6a3
|
7
|
+
data.tar.gz: 1e536bc89380c2851f38b950a51fc67a57be257249c18f4e59b6b4fa1198cf6deae23f13f71fe3591dea12512dc882236c2fdadb52a706f8795993aee459b4fc
|
data/lib/fxpotato/cli.rb
CHANGED
@@ -8,7 +8,11 @@ module FxPotato
|
|
8
8
|
method_option :date, :aliases => "-d", :desc => "A specific date to get the rate for, e.g. -d 2017-05-29"
|
9
9
|
def getrate(base, target)
|
10
10
|
date = options[:date] || Date.today
|
11
|
-
|
11
|
+
begin
|
12
|
+
puts "Exchange rate from #{base} to #{target} on #{date}: #{FxPotato.at(date, base, target)}"
|
13
|
+
rescue RuntimeError => message
|
14
|
+
puts message
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
data/lib/fxpotato/version.rb
CHANGED
data/lib/fxpotato.rb
CHANGED
@@ -10,9 +10,11 @@ module FxPotato
|
|
10
10
|
raise "Must specify date" if date.nil?
|
11
11
|
raise "Must specify from_currency" if from_currency.nil?
|
12
12
|
raise "Must specify to_currency" if to_currency.nil?
|
13
|
-
|
13
|
+
|
14
14
|
from = RateStore.get(self.repo, date, from_currency)
|
15
|
+
raise "Unable to find #{from_currency} on #{date}" if from.nil?
|
15
16
|
to = RateStore.get(self.repo, date, to_currency)
|
17
|
+
raise "Unable to find #{to_currency} on #{date}" if to.nil?
|
16
18
|
RateCalculator.calculate(from, to)
|
17
19
|
end
|
18
20
|
|