Brian Roberts knew his spot was coming up in the bottom of the ninth and then saw Brett Gardner getting ready to pinch hit.

At that point, even Roberts could put two and two together, realizing his night was over.

“I wasn’t thinking about it going into it, but when I saw Gardner getting loose, I figured he wasn’t hitting for [Yangervis] Solarte and Ichiro has been swinging the bat well,” Roberts said after the Yankees 4-2 loss to the Red Sox on Friday night in The Bronx. “So I thought it was probably for me.”

It’s not the kind of spot in which Roberts typically finds himself, but in the middle of a 1-for-20 slide, the second baseman couldn’t argue with manager Joe Girardi’s decision.

“It’s one of those things, when you’re not swinging the bat great, it’s understandable,” said Roberts, who went 0-for-2 with a walk Friday. “Gardner’s been productive lately and we needed to try to get something going, so I wasn’t blown away.”

He’d like to be in a different spot the next time Girardi is in a similar position.

“Obviously, you want to hit,” Roberts said. “Especially at that point of the game, where you’re trying to extend things.”

Gardner struck out against the right-handed Edward Mujica to end the game, but even with that result, it would be hard to argue with Girardi’s call — especially since Roberts has been particularly weak from the left side of the plate (2-for-17) this year.

Roberts didn’t come with the expensive price tag like some of the other free agents the Yankees signed this offseason, but he had considerable success at the plate until injuries derailed his career.

While he has been able to stay healthy in the season’s first month, Roberts has not been able to find a rhythm at the plate. Since getting three hits on April 2, has just one single and has knocked in only one run — although he has scored three times and has seven walks in that span.

“Nothing’s really changed a whole lot,” Roberts said. “Sometimes you just go through these periods. But you figure if you stick with the process, the results will come.”