I assume $n \ge 2$.
Let $\mathbf{1}$ denote the all ones vector so that $\mathbf{11}^\top$ is the all ones matrix.
$$A = b\mathbf{11}^\top + (a-b) I.$$
The eigenvalues of $b\mathbf{11}^\top$ are
- $bn$ with multiplicity $1$ (corresponding to eigenvector $\mathbf{1}$) and
- $0$ with multiplicity $n-1$ (the nullspace of $b\mathbf{11}^\top$ is the subspace orthogonal to $\mathbf{1}$).
[To be clear, I am still allowing $bn=0$ to be possible, in which case $0$ is an eigenvalue with multiplicity $n$.]
Thus the eigenvalues of $A$ are
- $bn+a-b=a+(n-1)b$ with multiplicity $1$ and
- $a-b$ with multiplicity $n-1$.
From here you can get all the possible ranks:
- rank $0$ if $a=b=0$
- rank $1$ if $a=b \ne 0$
- rank $n-1$ if $a=-(n-1)b$ and $b \ne 0$
- rank $n$ if $a \ne b$ and $a \ne -(n-1)b$.
With the extra restrictions $a\ge 0$ and $b\ge 0$, the possibilities are more limited.
- rank $0$ if $a=b=0$
- rank $1$ if $a=b \ne 0$
- rank $n$ otherwise