Method: Gem::Version#approximate_recommendation

Defined in:
lib/rubygems/version.rb

#approximate_recommendationObject

A recommended version for use with a ~> Requirement.



342
343
344
345
346
347
348
349
350
351
352
# File 'lib/rubygems/version.rb', line 342

def approximate_recommendation
  segments = self.segments

  segments.pop    while segments.any? {|s| String === s }
  segments.pop    while segments.size > 2
  segments.push 0 while segments.size < 2

  recommendation = "~> #{segments.join(".")}"
  recommendation += ".a" if prerelease?
  recommendation
end