Guest User

Untitled

a guest
Feb 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. require 'socket'
  2. $my_socket = '/tmp/proxy-client'
  3.  
  4. class ProxyClass
  5. private_class_method :new
  6. @@proxy_con = nil
  7. def ProxyClass.create
  8. @@proxy_con = UNIXSocket.open($my_socket) unless @@proxy_con
  9. @@proxy_con
  10. end
  11. end
  12. connection_object = ProxyClass.create
  13. on_high_quotes = Array.new(5,Array.new(3))
  14. i = 0
  15. on_high_symbols = ['CTS','IBM','INFY','ABBI','DELL']
  16. on_high_symbols.each do |x|
  17. sym = '310<'+x+'>'
  18. connection_object.send(sym,0)
  19. qvalue = connection_object.recvfrom(124)[0]
  20. qvalue = qvalue.gsub(/[<>]/,'|')
  21. on_high_quotes[i][0] = qvalue.split('|')[2]
  22. on_high_quotes[i][1] = qvalue.split('|')[12]
  23. prev_val = qvalue.split('|')[11].to_f
  24. on_high_quotes[i][2] = ((on_high_quotes[i][0].to_f- prev_val)*100)/on_high_quotes[i][0].to_f
  25. puts on_high_quotes[i][0]
  26. i = i + 1
  27. end
  28.  
  29. puts on_high_quotes[0][0]
Add Comment
Please, Sign In to add comment