How to compare version strings in Ruby

Sometimes you need to support different versions of an API inside your ruby code. And, sometime, you will need to compare version strings in order to make a feature available.

But how do we compare if a version is greater than another one? It’s simple: use Gem::Version!

It’s part of the stdlib, so you don’t need to import anything else! Just use it and you will get full version comparison inside your ruby code!