Method: Kafka::Protocol::Encoder#write_array

Defined in:
lib/kafka/protocol/encoder.rb

#write_array(array, &block) ⇒ nil

Writes an array to the IO object.

Each item in the specified array will be yielded to the provided block; it's the responsibility of the block to write those items using the encoder.

Parameters:

  • array (Array)

Returns:

  • (nil)


78
79
80
81
82
83
84
85
86
# File 'lib/kafka/protocol/encoder.rb', line 78

def write_array(array, &block)
  if array.nil?
    # An array can be null, which is different from it being empty.
    write_int32(-1)
  else
    write_int32(array.size)
    array.each(&block)
  end
end