Class: Thrift::IOStreamTransport

Inherits:
Transport show all
Defined in:
lib/thrift/transport.rb

Overview

Very very simple implementation of wrapping two objects, one with a #read method and one with a #write method, into a transport for thrift.

Assumes both objects are open, remain open, don’t require flushing, etc.

Instance Method Summary collapse

Methods inherited from Transport

#flush, #open, #read_all

Constructor Details

#initialize(input, output) ⇒ IOStreamTransport

Returns a new instance of IOStreamTransport.



307
308
309
310
# File 'lib/thrift/transport.rb', line 307

def initialize(input, output)
  @input = input
  @output = output
end

Instance Method Details

#closeObject



315
# File 'lib/thrift/transport.rb', line 315

def close; @input.close; @output.close end

#open?Boolean

Returns:

  • (Boolean)


312
# File 'lib/thrift/transport.rb', line 312

def open?; not @input.closed? or not @output.closed? end

#read(sz) ⇒ Object



313
# File 'lib/thrift/transport.rb', line 313

def read(sz); @input.read(sz) end

#to_ioObject

we’re assuming this is used in a IO.select for reading



316
# File 'lib/thrift/transport.rb', line 316

def to_io; @input end

#write(buf) ⇒ Object



314
# File 'lib/thrift/transport.rb', line 314

def write(buf); @output.write(buf) end