Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#getEx(url, symbol) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/btcl.rb', line 49

def getEx(url, symbol)
	begin
		open(url) do |d| 
		  json = JSON.parse(d.read)
		  json.each do |a|
		  	a.each do |k, v|
		  		if k == "symbol" and v == symbol
		  			return true, a		  			
		  		end
		  	end
		  end
		  return false, "bity Error: Symbol not found in bitcoin API."
		end
	rescue SocketError => e 
		return false, "bity Error: Could not connect to bitcoincharts API."
	end
end

#getTop(url) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/btcl.rb', line 26

def getTop(url)
	exchanges = []
	names = []
	begin
		open(url) do |d|
			json = JSON.parse(d.read)
			$top.each do |k, v|
				json.each do |a|
					if a.has_value?(v)
						exchanges << a
						names << k
					end
				end
		  	end

		  	return true, exchanges, names
		end
	rescue SocketError => e
		return false, "bity Error: Could not connect to bitcoincharts API."

	end
end