Module: Hx::Interop::Reader

Included in:
Interceptor::Read, ReaderWriter, StreamReader
Defined in:
lib/interop/reader.rb

Overview

Anything from which you can read a message.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(*args, &block) ⇒ Object



5
6
7
# File 'lib/interop/reader.rb', line 5

def self.new(*args, &block)
  StreamReader.new *args, &block
end

Instance Method Details

#readMessage

Read a message from the stream, blocking until a completed message is read.

Returns:



11
12
13
# File 'lib/interop/reader.rb', line 11

def read
  _read
end

#read_all {|| ... } ⇒ Enumerable, Reader

Yields messages as they are read. Returns self when EOF is reached.

Yield Parameters:

Returns:



18
19
20
21
22
23
24
25
26
27
# File 'lib/interop/reader.rb', line 18

def read_all
  return enum_for :read_all unless block_given?

  loop do
    yield read
  rescue EOFError
    break
  end
  self
end