aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/platform.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/platform.rb')
-rw-r--r--lib/rubygems/platform.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index 7abc15ef94..5e932cd592 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -1,7 +1,8 @@
require 'rubygems'
+##
# Available list of platforms for targeting Gem installations.
-#
+
class Gem::Platform
@local = nil
@@ -122,11 +123,20 @@ class Gem::Platform
to_a.compact.join '-'
end
+ ##
+ # Is +other+ equal to this platform? Two platforms are equal if they have
+ # the same CPU, OS and version.
+
def ==(other)
self.class === other and
@cpu == other.cpu and @os == other.os and @version == other.version
end
+ ##
+ # Does +other+ match this platform? Two platforms match if they have the
+ # same CPU, or either has a CPU of 'universal', they have the same OS, and
+ # they have the same version, or either has no version.
+
def ===(other)
return nil unless Gem::Platform === other
@@ -140,6 +150,10 @@ class Gem::Platform
(@version.nil? or other.version.nil? or @version == other.version)
end
+ ##
+ # Does +other+ match this platform? If +other+ is a String it will be
+ # converted to a Gem::Platform first. See #=== for matching rules.
+
def =~(other)
case other
when Gem::Platform then # nop