# File lib/mongo/uri.rb, line 258
    def initialize(string, options = {})
      @string = string
      @options = options
      parsed_scheme, _, remaining = string.partition(SCHEME_DELIM)
      raise_invalid_error!(INVALID_SCHEME) unless parsed_scheme == scheme
      parse!(remaining)

      # The URI options spec requires that we raise an error if there are conflicting values of
      # 'tls' and 'ssl'. In order to fulfill this, we parse the values of each instance into an
      # array; assuming all values in the array are the same, we replace the array with that value.
      unless @uri_options[:ssl].nil? || @uri_options[:ssl].empty?
        unless @uri_options[:ssl].uniq.length == 1
          raise_invalid_error_no_fmt!("all instances of 'tls' and 'ssl' must have the same value")
        end

        @uri_options[:ssl] = @uri_options[:ssl].first
      end

      # Check for conflicting TLS insecure options.
      unless @uri_options[:ssl_verify].nil?
        unless @uri_options[:ssl_verify_certificate].nil?
          raise_invalid_error_no_fmt!("'tlsInsecure' and 'tlsAllowInvalidCertificates' cannot both be specified")
        end

        unless @uri_options[:ssl_verify_hostname].nil?
          raise_invalid_error_no_fmt!("tlsInsecure' and 'tlsAllowInvalidHostnames' cannot both be specified")
        end
      end
    end