An older version of Ruby ships with OSX by default, the version is 1.8.7 which is now officially retired by its developers.
To upgrade to the latest stable version of Ruby, you going to need Xcode and Homebrew installed first, Xcode does the heavy lifting for compiling programs and Homebrew works as the package manager making sure any apps it installs plays nicely with the existing operating system
Get Xcode and Homebrew cooking
Install Ruby
brew install ruby
Add latest Ruby to the shell path
With 2 versions of Ruby now installed you need to prioritise the latest one in your shell path, in either ~/.bash_profile or ~/.bashrc add in
/usr/local/opt/ruby/bin
Do the path line looks something like this
export PATH="/usr/local/opt/ruby/bin:$PATH"
Reload the shell
source ~/.bash_profile
Check Ruby
ruby --version ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
To update Ruby, just run:
gem update --system
That’s it, the latest version is now installed whilst the older version is still on the OS the path points to the newer version and any gems will need to be reinstalled.