Class: GQTP::Backend::Synchronous::IO
- Inherits:
-
Object
- Object
- GQTP::Backend::Synchronous::IO
- Defined in:
- lib/gqtp/backend/synchronous.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(real_io) ⇒ IO
constructor
A new instance of IO.
- #read(size = nil) {|data| ... } ⇒ Object
- #write(*chunks) ⇒ Object
Constructor Details
#initialize(real_io) ⇒ IO
Returns a new instance of IO.
33 34 35 |
# File 'lib/gqtp/backend/synchronous.rb', line 33 def initialize(real_io) @real_io = real_io end |
Instance Method Details
#close ⇒ Object
55 56 57 |
# File 'lib/gqtp/backend/synchronous.rb', line 55 def close @real_io.close end |
#read(size = nil) {|data| ... } ⇒ Object
49 50 51 52 53 |
# File 'lib/gqtp/backend/synchronous.rb', line 49 def read(size=nil) data = @real_io.read(size) yield(data) if block_given? Request.new(data) end |
#write(*chunks) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gqtp/backend/synchronous.rb', line 37 def write(*chunks) chunks.each do |chunk| until chunk.empty? written_bytes = @real_io.write(chunk) break if chunk.bytesize == written_bytes chunk = chunk[written_bytes..-1] end end yield if block_given? Request.new(nil) end |