trades 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/trades.rb +8 -2
  2. metadata +1 -1
data/lib/trades.rb CHANGED
@@ -1,19 +1,25 @@
1
- require 'socket'
2
1
  require 'rubygems'
2
+ require 'socket'
3
3
  require 'json'
4
4
 
5
5
  class Trades
6
6
  def initialize(args = [])
7
7
  @socket = TCPSocket.open("bitcoincharts.com", 27007)
8
8
 
9
+ # Convert the exchange names to lowercase
10
+ args.collect do |exchange|
11
+ exchange.downcase
12
+ end
13
+
9
14
  # thUSD | 2011-06-27 23:00:55 | USD | 17.05 | 0.5 |
10
15
  puts "Exchange | Date and time | Currency | Price | Volume |"
11
16
 
12
17
  while data = @socket.gets do
13
18
  if data.length > 0
14
19
  begin
15
- j = JSON.parse(data.strip)
20
+ j = JSON.parse(data.strip.tr("\x00", '')) # Delete all \x00
16
21
  rescue
22
+ puts "Error: #{$!}\n #{data}"
17
23
  end
18
24
 
19
25
  if args.length == 0 or args.include?(j['symbol'].downcase) then
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: trades
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.1"
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Waxjar