IO::StreamSourceIOStreamStringBuffer

class StringBuffer

A specialized string buffer for binary data with automatic encoding handling.

Definitions

def initialize

Initialize a new string buffer with binary encoding.

Implementation

def initialize
	super
	
	force_encoding(BINARY)
end

def << string

Append a string to the buffer, converting to binary encoding if necessary.

Signature

parameter string String

The string to append.

returns StringBuffer

Self for method chaining.

Implementation

def << string
	if string.encoding == BINARY
		super(string)
	else
		super(string.b)
	end
	
	return self
end