Class: PostgresPR::DataRow

Inherits:
Message
  • Object
show all
Defined in:
lib/postgres-pr/message.rb

Constant Summary

Constants inherited from Message

Message::MsgTypeMap

Instance Method Summary collapse

Methods inherited from Message

create, dump, fields, read, register_message_type

Instance Method Details

#dumpObject



264
265
266
267
268
269
270
271
272
273
# File 'lib/postgres-pr/message.rb', line 264

def dump
  sz = @columns.inject(2) {|sum, col| sum + 4 + (col ? col.size : 0)}
  super(sz) do |buffer|
    buffer.write_int16_network(@columns.size)
    @columns.each {|col|
      buffer.write_int32_network(col ? col.size : -1)
      buffer.write(col) if col
    }
  end
end

#parse(buffer) ⇒ Object



275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/postgres-pr/message.rb', line 275

def parse(buffer)
  super do
    n_cols = buffer.read_int16_network
    @columns = (1..n_cols).collect {
      len = buffer.read_int32_network 
      if len == -1
        nil
      else
        buffer.read(len)
      end
    }
  end
end