class Net::SSH::Buffer

def write_moved(string)

to the method. This way we can mutate the string.
Optimized version of write where the caller gives up ownership of string
def write_moved(string)
  @content <<
    if string.frozen?
      string.dup.force_encoding('BINARY')
    else
      string.force_encoding('BINARY')
    end
  self
end