Ubuntu ships with ancient versions of the Ruby interpreter and its tools. The preferred method to installing the latest version of Ruby from source is using rbenv.
Install and setup
rbenv and its
ruby-build plugin from source as described here.
List the versions of Ruby available for installation:
$ rbenv install -l
$ rbenv install 2.1.5
Trying the latest
2.2.0 gave build errors on my system, but I was able to install
$ rbenv global 2.1.5
$ ruby --version
Now you can also install other gems using the
gem tool that is also built along with Ruby.
Tried with: rbenv 0.4.0 and Ubuntu 14.04