Answer
$f(x)=\left\{\begin{array}{ll}
x & -1 \leq x\leq 0\\
1 & 0\lt x\leq 2
\end{array}\right.$
(Other answers are also possible.)
Work Step by Step
We see that the left side of the graph corresponds to a line with a slope of $\frac{1}{1}=1$ and a $y$ intercept of $0$, e.g. $y=x$. We also see that the right side of the graph corresponds to a line with slope $0$ and $y$-intercept $1$, e.g. $y=1$. Thus the equation is:
$f(x)=\left\{\begin{array}{ll}
x & -1 \leq x\leq 0\\
1 & 0\lt x\leq 2
\end{array}\right.$