Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::Source#<=>
<=>(other)
lib/rubygems/source.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/source.rb, line 56
def <=>(other)
case other
when Gem::Source::Installed,
Gem::Source::Local,
Gem::Source::Lock,
Gem::Source::SpecificFile,
Gem::Source::Git,
Gem::Source::Vendor then
-1
when Gem::Source then
unless @uri
return 0 unless other.uri
return 1
end
return -1 unless other.uri
# Returning 1 here ensures that when sorting a list of sources, the
# original ordering of sources supplied by the user is preserved.
return 1 unless @uri.to_s == other.uri.to_s
0
end
end
Sources are ordered by installation preference.