Let $$f(x)=\begin{cases} -1, \quad & a \leq x \leq 0 \\ 1, \quad & 0 \leq x \leq b \end{cases}$$
It says in my book because of the Darboux theorem:
If $f:[a,b] \to \mathbb R$ is differentiable on segment $[a,b]$, then $\forall a_1, b_1 \in [a,b]: a_1<b_1\ \ \ \forall t \in [f'(a_1),f'(b_1)] \ : \exists c \in [a_1,b_1]: f'(c)=t$
I don't directly see this...
Firstly, you cannot have both $f(0)=+1$ and $f(0)=-1$, but that's hardly relevant.
And Darboux's theorem is an overkill. Just note that:
Any primitive $F$ would have to satisfy $F(x)=-x+c$ on $[a, 0)$ and $F(x)=x+d$ on $(0, b]$. Since it is differentiable (and hence continuous) at $x=0$, we need $c=d$, so in fact $F(x)=\left|x\right|+c$ and that's not differentiable at $x=0$ irrespective of the choice of $f(0)$.