def write_type(field_info, value)
      # if field_info is a Fixnum, assume it is a Thrift::Types constant
      # convert it into a field_info Hash for backwards compatibility
      if field_info.is_a? Fixnum
        field_info = {:type => field_info}
      end

      case field_info[:type]
      when Types::BOOL
        write_bool(value)
      when Types::BYTE
        write_byte(value)
      when Types::DOUBLE
        write_double(value)
      when Types::I16
        write_i16(value)
      when Types::I32
        write_i32(value)
      when Types::I64
        write_i64(value)
      when Types::STRING
        if field_info[:binary]
          write_binary(value)
        else
          write_string(value)
        end
      when Types::STRUCT
        value.write(self)
      else
        raise NotImplementedError
      end
    end
def write_type(field_info, value)
      # if field_info is a Fixnum, assume it is a Thrift::Types constant
      # convert it into a field_info Hash for backwards compatibility
      if field_info.is_a? Fixnum
        field_info = {:type => field_info}
      end

      case field_info[:type]
      when Types::BOOL
        write_bool(value)
      when Types::BYTE
        write_byte(value)
      when Types::DOUBLE
        write_double(value)
      when Types::I16
        write_i16(value)
      when Types::I32
        write_i32(value)
      when Types::I64
        write_i64(value)
      when Types::STRING
        if field_info[:binary]
          write_binary(value)
        else
          write_string(value)
        end
      when Types::STRUCT
        value.write(self)
      else
        raise NotImplementedError
      end
    end
Writes a field value based on the field information.

 field_info - A Hash containing the definition of the field:
              :type   - The Thrift::Types constant that determines how the value is written.
              :binary - A Boolean flag that indicates if Thrift::Types::STRING is a binary string (string without encoding).
 value      - The field's value to write; object type varies based on field_info[:type].

 Returns nothing.