Class: Farcall::SocketStream
- Inherits:
-
Object
- Object
- Farcall::SocketStream
- Defined in:
- lib/farcall/json_transport.rb
Overview
Stream-like object to wrap very strange ruby socket IO
Direct Known Subclasses
Instance Method Summary collapse
- #<<(data) ⇒ Object
- #eof? ⇒ Boolean
-
#initialize(socket) ⇒ SocketStream
constructor
A new instance of SocketStream.
- #read(length = 1) ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(socket) ⇒ SocketStream
Returns a new instance of SocketStream.
9 10 11 |
# File 'lib/farcall/json_transport.rb', line 9 def initialize socket @socket = socket end |
Instance Method Details
#<<(data) ⇒ Object
30 31 32 |
# File 'lib/farcall/json_transport.rb', line 30 def << data write data end |
#eof? ⇒ Boolean
26 27 28 |
# File 'lib/farcall/json_transport.rb', line 26 def eof? @socket.eof? end |
#read(length = 1) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/farcall/json_transport.rb', line 13 def read length=1 # data = '' # while data.length < length # data << @socket.recv(length - data.length, Socket::MSG_WAITALL) # end # data @socket.read length end |
#write(data) ⇒ Object
22 23 24 |
# File 'lib/farcall/json_transport.rb', line 22 def write data @socket.write data end |