coinjar 1.0.0.alpha.3 → 1.0.0.alpha.4
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/coinjar/fair_rate.rb +31 -6
- data/lib/coinjar/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 349ea541aa457db0f47a4e1fb09f7859020b0ca8
|
4
|
+
data.tar.gz: b880533bb371bab05025032241e1c3d0480de22d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c98263942dd80a189418d0047a1279268a34d06fbbf92ed72401ecb332ced994a6b3db56e21b8d2b45f50eb3a0714f446d404003aae1ea31de80c184ff881f36
|
7
|
+
data.tar.gz: 32296020af2cbcb5f0ebd5b38f5f2b9332ae65d1a91e70b68c847ac216c6c8e575a43bed42b2cab06a46600d4e375a3d4cd2e6cbbeafa6a317a00a8a9381a3af
|
data/lib/coinjar/fair_rate.rb
CHANGED
@@ -1,14 +1,39 @@
|
|
1
1
|
module CoinJar
|
2
2
|
class FairRate
|
3
|
-
|
3
|
+
|
4
4
|
attr_accessor :currency, :bid, :ask, :spot
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
|
6
|
+
def initialize(args)
|
7
|
+
reset(args)
|
8
|
+
end
|
9
|
+
|
10
|
+
def fetch
|
8
11
|
response = CoinJar.client.get("fair_rate/" + currency)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
self.bid = BigDecimal.new response[:bid]
|
13
|
+
self.ask = BigDecimal.new response[:ask]
|
14
|
+
self.spot = BigDecimal.new response[:spot]
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.get(currency = "USD")
|
19
|
+
fair_rate = self.new(currency: currency)
|
20
|
+
fair_rate.fetch
|
21
|
+
fair_rate
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.all
|
25
|
+
response = CoinJar.client.get("fair_rate/all")[:fair_rate]
|
26
|
+
response.map do |hash|
|
27
|
+
currency = hash.to_a[0][0]
|
28
|
+
values = hash.to_a[0][1]
|
29
|
+
self.new(currency: currency, bid: values[:bid], ask: values[:ask], spot: values[:spot])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def reset(args)
|
34
|
+
args.each do |k,v|
|
35
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
36
|
+
end
|
12
37
|
end
|
13
38
|
|
14
39
|
end
|
data/lib/coinjar/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coinjar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.alpha.
|
4
|
+
version: 1.0.0.alpha.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CoinJar Pty Ltd
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|