coins 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/coins +1 -2
- data/lib/coins.rb +22 -18
- 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: e7bb004073b510552aa2d44ca26077789f600d2e
|
4
|
+
data.tar.gz: a7385ccad00023b74912708055b24b650d82ab40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f81a849e500e1a4b011ba96a8bef15cbcd61ca911e85ff6b2668ec9fd9ed332baf95a980e18f1652a3530b9c547545b14e3f6947e811321b2f7d7f42de02c0a4
|
7
|
+
data.tar.gz: 06e3a7d290cf5f8b22ac4def775452422f2b628c137288855cc5c67aed0d8016e556a71fdb68fde96e08f06df2777b2701f79e1d7d35997148630d99f560f88b
|
data/bin/coins
CHANGED
data/lib/coins.rb
CHANGED
@@ -2,10 +2,6 @@ require 'net/http'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
class Coins
|
5
|
-
def initialize
|
6
|
-
parseArgs
|
7
|
-
end
|
8
|
-
|
9
5
|
def setRate base
|
10
6
|
begin
|
11
7
|
@exchange = JSON.parse Net::HTTP.get(URI 'http://api.fixer.io/latest?base=' + base)
|
@@ -16,20 +12,28 @@ class Coins
|
|
16
12
|
end
|
17
13
|
|
18
14
|
def help
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
15
|
+
help = <<EOF
|
16
|
+
|
17
|
+
A simple live terminal currency exchange rate converter in Ruby
|
18
|
+
The currencies are retrieved from fixer.io which is a
|
19
|
+
'Foreign exchange rates and currency conversion API'
|
20
|
+
which is a JSON API published by the 'European Central Bank'.
|
21
|
+
|
22
|
+
The rates are updated daily around 4 PM CET
|
23
|
+
|
24
|
+
Usage:
|
25
|
+
`coins [rate(s)] [base/against] / [from] num(float/int ){CUR} [to] {CUR}`
|
26
|
+
where CUR is the three letter currency
|
27
|
+
(e.g. USD, GBP NOK, EUR, RUB, etc...)
|
28
|
+
use 'from `n` `CUR` to `CUR(other)`' toconvert between currencies.
|
29
|
+
use 'rates' to list all rates (see `base` also) or 'rate `CUR`'
|
30
|
+
to see the rate for one single currency.
|
31
|
+
use 'base `CUR`' or 'agains `CUR`' to change what the exchange
|
32
|
+
rates compare to.
|
33
|
+
Default rate base is USD
|
34
|
+
|
35
|
+
EOF
|
36
|
+
puts help
|
33
37
|
end
|
34
38
|
|
35
39
|
def args? this
|