def write(objects, from: nil, as: nil)
      stream.pos = from if from
      as ||= objects.class if objects.class.ancestors.include?(MemoryIO::Types::Type)
      return stream.write(objects) if as.nil?

      conv = to_proc(as, :write)
      Array(objects).map { |o| conv.call(stream, o) }
    end
def write(objects, from: nil, as: nil)
      stream.pos = from if from
      as ||= objects.class if objects.class.ancestors.include?(MemoryIO::Types::Type)
      return stream.write(objects) if as.nil?

      conv = to_proc(as, :write)
      Array(objects).map { |o| conv.call(stream, o) }
    end
Write to stream.

 @param [Object, Array<Object>] objects
   Objects to be written.

 @param [Integer] from
   The position to start to write.

 @param [nil, Symbol, Proc] as
   Decide the method to process writing procedure.
   See {MemoryIO::Types} for all supported types.

   A +Proc+ is allowed, which should accept +stream+ and one object as arguments.

   If +objects+ is a descendent instance of {Types::Type} and +as+ is +nil,
   +objects.class+ will be used for +as+.
   Otherwise, when +as = nil+, this method will simply call +stream.write(objects)+.

 @return [void]

 @example
   stream = StringIO.new
   io = MemoryIO::IO.new(stream)
   io.write('abcd')
   stream.string
   #=> "abcd"

   io.write([1, 2, 3, 4], from: 2, as: :u16)
   stream.string
   #=> "ab\x01\x00\x02\x00\x03\x00\x04\x00"

   io.write(['A', 'BB', 'CCC'], from: 0, as: :c_str)
   stream.string
   #=> "A\x00BB\x00CCC\x00\x00"
 @example
   stream = StringIO.new
   io = MemoryIO::IO.new(stream)
   io.write(%w[123 4567], as: ->(s, str) { s.write(str.size.chr + str) })
   stream.string
   #=> "\x03123\x044567"

 @example
   stream = StringIO.new
   io = MemoryIO::IO.new(stream)
   cpp_string = CPP::String.new('A' * 4, 15, 16)
   # equivalent to io.write(cpp_string, as: :'cpp/string')
   io.write(cpp_string)
   stream.string
   #=> "\x10\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00AAAA\x00"
 @see Types