Ruby 4.1 リファレンスマニュアル

instance method Gem::Version#approximate_recommendation

approximate_recommendation -> StringRuby 2.0.0 から[permalink][rdoc][edit]
() → String

self を元にした、バージョン要求の推奨文字列を返します。

self の先頭 2 つの数値要素(メジャー・マイナー)を使った X.Y の形式で、 >= X.Y という文字列を返します(Ruby 4.0 までは ~> X.Y でした)。要素が 1 つしかない場合は 0 を補います。self が Gem::Version#prerelease? であれば、末尾に .a を追加します。

例
p Gem::Version.new("1.2.3").approximate_recommendation   # => ">= 1.2"
p Gem::Version.new("2").approximate_recommendation       # => ">= 2.0"
p Gem::Version.new("1.2.3.a").approximate_recommendation # => ">= 1.2.a"

[SEE_ALSO] Gem::Version#segments, Gem::Version#prerelease?