rubitcoin 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a69e5622e594cc5c7cd00f77dd1e2f100d4be1ce
4
- data.tar.gz: 51348c3709d6e71cc44e6170ba41c944ec29a193
3
+ metadata.gz: 894a2c1e3537f7e22797e0e1d6d73e4bab6e486e
4
+ data.tar.gz: 10f364b27d1c85f106cba467391ada58522f5811
5
5
  SHA512:
6
- metadata.gz: 822c700aa28aa171c9bfc7b69eba18a689410e54c69539b057339e4c74c7ded4a1f87e31733fdd96de1f1bc38db77f4ac195a44b2b245eaac70dca9292a6c739
7
- data.tar.gz: 4f4422dbb44c8262920b80198c875cb91c359954e0cb974589e9a10578b6dcb514e4b7834cc00d74ac0c63b73f169be254bd11066b3da74c14c1da096a8ab7b9
6
+ metadata.gz: baf301e0f0ba9dcd96efb30990f36f5b058e3166c41396ad88a8858ff73b24a26484446c4857e29439f86c3e552fee9bdd45116c6cd51768035717e9e4e1b67c
7
+ data.tar.gz: 1f358f3650c74564b80bea8965de8cf31869b442d1905f3dc08a2e8505edaf2fc155e8752b8cf886fa770c42eb5219fe2e471646de14cf1fa1eab8574bd1aa78
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rubitcoin
2
2
 
3
- TODO: Write a gem description
3
+ Super simple Bitcoin ticker.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,10 +18,18 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install rubitcoin
20
20
 
21
- ## Usage
21
+ ## How to
22
22
 
23
- TODO: Write usage instructions here
23
+ ```rb
24
+ require 'rubitcoin'
24
25
 
26
+ Rubitcoin.fetch
27
+ #=> {:high=>223.15, :last=>208.39, :timestamp=>1421461371.0, :bid=>207.95, :vwap=>210.62, :volume=>32705.34241534, :low=>198.04, :ask=>208.21}
28
+
29
+ Rubitcoin.high
30
+ #=> 223.15
31
+
32
+ ```
25
33
  ## Contributing
26
34
 
27
35
  1. Fork it ( https://github.com/[my-github-username]/Rubitcoin/fork )
@@ -1,3 +1,3 @@
1
1
  class Rubitcoin
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/rubitcoin.rb CHANGED
@@ -1,22 +1,23 @@
1
1
  require 'open-uri'
2
2
  require 'json'
3
-
3
+ require 'pry'
4
4
  class Rubitcoin
5
- END_POINT = "https://www.bitstamp.net/api/ticker/"
5
+ END_POINT = "https://btc-e.com/api/3/ticker"
6
6
  class << self
7
- def fetch
8
- Hash.[] raw_fetch.map { |k, v| [k.to_sym, v.to_f] }
7
+ def fetch(currency=:usd)
8
+ Hash.[] raw_fetch(currency).map { |k, v| [k.to_sym, v.to_f] }
9
9
  end
10
10
 
11
- %w|high low bid ask volume last timestamp|.each do |mth|
12
- define_method(mth) do
13
- raw_fetch[mth].to_f
11
+ %w|high low avg vol vol_cur last buy sell updated|.each do |mth|
12
+ define_method(mth) do |currency=:usd|
13
+ raw_fetch(currency)[mth].to_f
14
14
  end
15
15
  end
16
16
 
17
17
  private
18
- def raw_fetch
19
- JSON.load open END_POINT
18
+ def raw_fetch(currency)
19
+ rslt = JSON.load open "#{END_POINT}/btc_#{currency}"
20
+ rslt.values.first
20
21
  end
21
22
  end
22
23
  end
@@ -1,14 +1,27 @@
1
1
  require 'minitest_helper'
2
2
 
3
3
  class TestRubitcoin < MiniTest::Unit::TestCase
4
- def test_general
4
+ def test_usd
5
5
  assert_instance_of Hash, Rubitcoin.fetch
6
6
  assert_instance_of Float, Rubitcoin.high
7
- assert_instance_of Float, Rubitcoin.low
8
- assert_instance_of Float, Rubitcoin.bid
9
- assert_instance_of Float, Rubitcoin.ask
10
- assert_instance_of Float, Rubitcoin.volume
7
+ assert_instance_of Float, Rubitcoin.avg
8
+ assert_instance_of Float, Rubitcoin.vol
9
+ assert_instance_of Float, Rubitcoin.vol_cur
11
10
  assert_instance_of Float, Rubitcoin.last
12
- assert_instance_of Float, Rubitcoin.timestamp
11
+ assert_instance_of Float, Rubitcoin.buy
12
+ assert_instance_of Float, Rubitcoin.sell
13
+ assert_instance_of Float, Rubitcoin.updated
14
+ end
15
+
16
+ def test_rur
17
+ assert_instance_of Hash, Rubitcoin.fetch(:rur)
18
+ assert_instance_of Float, Rubitcoin.high(:rur)
19
+ assert_instance_of Float, Rubitcoin.avg(:rur)
20
+ assert_instance_of Float, Rubitcoin.vol(:rur)
21
+ assert_instance_of Float, Rubitcoin.vol_cur(:rur)
22
+ assert_instance_of Float, Rubitcoin.last(:rur)
23
+ assert_instance_of Float, Rubitcoin.buy(:rur)
24
+ assert_instance_of Float, Rubitcoin.sell(:rur)
25
+ assert_instance_of Float, Rubitcoin.updated(:rur)
13
26
  end
14
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubitcoin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - gogotanaka