Class: XDR::RPC::RecordReader

Inherits:
Object
  • Object
show all
Includes:
Concerns::ReadsBytes
Defined in:
lib/xdr/rpc/record_reader.rb

Constant Summary collapse

LAST_MASK =
0x80000000
LENGTH_MASK =
0x7FFFFFFF

Instance Method Summary collapse

Instance Method Details

#read(io) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/xdr/rpc/record_reader.rb', line 7

def read(io)
  header = read_bytes(io, 4).unpack1("L>")
  length = header & LENGTH_MASK
  last = (header & LAST_MASK) > 0
  raw_content = read_bytes(io, length)
  content = StringIO.new(raw_content)

  XDR::RPC::Record.new(last, length, content)
end