That's a strange comment. OS X does indeed ship with Ruby. Maybe you are thinking about Rails? Or how developers often update it to a different version before using it? Mac OS X Mavericks includes Ruby 2.0.0p247.
In spite of the fact that Ruby is indeed standard on Mac OS X, a simple shell script would have been clearly lighter. However, for proper JSON escaping of the snippet, you need a full set of replacing rules, which kind of kills the purpose. So I give up.