Sha256: b074d0ff4c8d10bb862af28c4d7dd767cee2988b6c6b86c6d4734a01245de9db
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
require 'socket' module IB class IBSocket < TCPSocket # send nice null terminated binary data into socket def send data self.syswrite(data.to_s + EOL) end def read_string string = self.gets(EOL) until string # Silently ignores nils string = self.gets(EOL) sleep 0.1 end string.chop end def read_int self.read_string.to_i end def read_int_max str = self.read_string str.nil? || str.empty? ? nil : str.to_i end def read_boolean self.read_string.to_i != 0 end def read_decimal # Floating-point numbers shouldn't be used to store money... # ...but BigDecimals are too unwieldy to use in this case... maybe later # self.read_string.to_d self.read_string.to_f end def read_decimal_max str = self.read_string # Floating-point numbers shouldn't be used to store money... # ...but BigDecimals are too unwieldy to use in this case... maybe later # str.nil? || str.empty? ? nil : str.to_d str.nil? || str.empty? ? nil : str.to_f end end # class IBSocket end # module IB
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ib-ruby-0.5.18 | lib/ib-ruby/socket.rb |
ib-ruby-0.5.17 | lib/ib-ruby/socket.rb |
ib-ruby-0.5.16 | lib/ib-ruby/socket.rb |