Class: Cosmos::Stream
Overview
Class that implments the following methods: read, write(data), connect, connected? and disconnect. Streams are simply data sources which StreamProtocol classes read and write to. This separation of concerns allows Streams to simply focus on getting and sending raw data while the higher level processing occurs in StreamProtocol.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#raw_logger_pair ⇒ RawLoggerPair
Raw logger pair associated with this stream.
Instance Method Summary collapse
-
#connect ⇒ Object
Connects the stream.
-
#connected? ⇒ Boolean
True if connected or false otherwise.
-
#disconnect ⇒ Object
Disconnects the stream Note that streams are not designed to be reconnected and must be recreated.
-
#read ⇒ Object
Expected to return any amount of data on success, or a blank string on closed/EOF, and may raise Timeout::Error, or other errors.
-
#read_nonblock ⇒ Object
Expected to always return immediately with data if available or an empty string.
-
#write(data) ⇒ Object
Expected to write complete set of data.
Instance Attribute Details
#raw_logger_pair ⇒ RawLoggerPair
Returns Raw logger pair associated with this stream.
23 24 25 |
# File 'lib/cosmos/streams/stream.rb', line 23 def raw_logger_pair @raw_logger_pair end |
Instance Method Details
#connect ⇒ Object
Connects the stream
46 47 48 |
# File 'lib/cosmos/streams/stream.rb', line 46 def connect raise "connect not defined by Stream" end |
#connected? ⇒ Boolean
Returns true if connected or false otherwise.
51 52 53 |
# File 'lib/cosmos/streams/stream.rb', line 51 def connected? raise "connected? not defined by Stream" end |
#disconnect ⇒ Object
Disconnects the stream Note that streams are not designed to be reconnected and must be recreated
57 58 59 |
# File 'lib/cosmos/streams/stream.rb', line 57 def disconnect raise "disconnect not defined by Stream" end |
#read ⇒ Object
Expected to return any amount of data on success, or a blank string on closed/EOF, and may raise Timeout::Error, or other errors
27 28 29 |
# File 'lib/cosmos/streams/stream.rb', line 27 def read raise "read not defined by Stream" end |
#read_nonblock ⇒ Object
Expected to always return immediately with data if available or an empty string. Should not raise errors
33 34 35 |
# File 'lib/cosmos/streams/stream.rb', line 33 def read_nonblock raise "read_nonblock not defined by Stream" end |
#write(data) ⇒ Object
Expected to write complete set of data. May raise Timeout::Error or other errors.
41 42 43 |
# File 'lib/cosmos/streams/stream.rb', line 41 def write(data) raise "write not defined by Stream" end |