Class: Hx::Interop::Connection
- Inherits:
-
Object
- Object
- Hx::Interop::Connection
- Includes:
- ReaderWriter
- Defined in:
- lib/interop/connection.rb
Overview
Combines a Reader and a Writer
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(reader, writer) ⇒ Connection
constructor
A new instance of Connection.
Methods included from Reader
Methods included from Writer
Constructor Details
#initialize(reader, writer) ⇒ Connection
Returns a new instance of Connection.
24 25 26 27 28 29 30 |
# File 'lib/interop/connection.rb', line 24 def initialize(reader, writer) raise ArgumentError, "Expected a #{Reader}" unless reader.is_a? Reader raise ArgumentError, "Expected a #{Writer}" unless writer.is_a? Writer @reader = reader @writer = writer end |
Class Method Details
.build(reader, writer = reader) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/interop/connection.rb', line 13 def self.build(reader, writer = reader) return reader if reader.is_a?(ReaderWriter) && writer.equal?(reader) reader = StreamReader.new(reader) if reader.respond_to? :readline writer = StreamWriter.new(writer) if writer.respond_to? :puts new reader, writer end |