Class: PostgresPR::StartupMessage
- Defined in:
- lib/postgres-pr/message.rb
Constant Summary collapse
- PROTO_VERSION =
196608
3 << 16
Constants inherited from Message
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(params) ⇒ StartupMessage
constructor
A new instance of StartupMessage.
Methods inherited from Message
create, dump, #parse, read, register_message_type
Constructor Details
#initialize(params) ⇒ StartupMessage
Returns a new instance of StartupMessage.
282 283 284 |
# File 'lib/postgres-pr/message.rb', line 282 def initialize(params) @params = params end |
Instance Method Details
#dump ⇒ Object
286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/postgres-pr/message.rb', line 286 def dump params = @params.reject{|k,v| v.nil?} sz = params.inject(4 + 4) {|sum, kv| sum + kv[0].size + 1 + kv[1].size + 1} + 1 buffer = Buffer.of_size(sz) buffer.write_int32(sz) buffer.write_int32(PROTO_VERSION) params.each_pair do |key, value| buffer.write_cstring(key) buffer.write_cstring(value) end buffer.write_byte(0) buffer.content end |