Class: PostgresPR::RowDescription
- Defined in:
- lib/postgres-pr/message.rb
Defined Under Namespace
Classes: FieldInfo
Constant Summary
Constants inherited from Message
Instance Method Summary collapse
Methods inherited from Message
create, dump, fields, read, register_message_type
Instance Method Details
#dump ⇒ Object
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'lib/postgres-pr/message.rb', line 425 def dump sz = @fields.inject(2) {|sum, fld| sum + 18 + fld.name.size + 1 } super(sz) do |buffer| buffer.write_int16_network(@fields.size) @fields.each { |f| buffer.write_cstring(f.name) buffer.write_int32_network(f.oid) buffer.write_int16_network(f.attr_nr) buffer.write_int32_network(f.type_oid) buffer.write_int16_network(f.typlen) buffer.write_int32_network(f.atttypmod) buffer.write_int16_network(f.formatcode) } end end |
#parse(buffer) ⇒ Object
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'lib/postgres-pr/message.rb', line 441 def parse(buffer) super do n_fields = buffer.read_int16_network @fields = (1..n_fields).collect { f = FieldInfo.new f.name = buffer.read_cstring f.oid = buffer.read_int32_network f.attr_nr = buffer.read_int16_network f.type_oid = buffer.read_int32_network f.typlen = buffer.read_int16_network f.atttypmod = buffer.read_int32_network f.formatcode = buffer.read_int16_network f } end end |