aboutsummaryrefslogtreecommitdiffstats
path: root/lib/set.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/set.rb')
-rw-r--r--lib/set.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/set.rb b/lib/set.rb
index a8f4345f35..d1f99e0eb3 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -219,7 +219,7 @@ class Set
# Returns true if the set is a superset of the given set.
def superset?(set)
case
- when set.instance_of?(self.class)
+ when set.instance_of?(self.class) && @hash.respond_to?(:>=)
@hash >= set.instance_variable_get(:@hash)
when set.is_a?(Set)
size >= set.size && set.all? { |o| include?(o) }
@@ -232,7 +232,7 @@ class Set
# Returns true if the set is a proper superset of the given set.
def proper_superset?(set)
case
- when set.instance_of?(self.class)
+ when set.instance_of?(self.class) && @hash.respond_to?(:>)
@hash > set.instance_variable_get(:@hash)
when set.is_a?(Set)
size > set.size && set.all? { |o| include?(o) }
@@ -245,7 +245,7 @@ class Set
# Returns true if the set is a subset of the given set.
def subset?(set)
case
- when set.instance_of?(self.class)
+ when set.instance_of?(self.class) && @hash.respond_to?(:<=)
@hash <= set.instance_variable_get(:@hash)
when set.is_a?(Set)
size <= set.size && all? { |o| set.include?(o) }
@@ -258,7 +258,7 @@ class Set
# Returns true if the set is a proper subset of the given set.
def proper_subset?(set)
case
- when set.instance_of?(self.class)
+ when set.instance_of?(self.class) && @hash.respond_to?(:<)
@hash < set.instance_variable_get(:@hash)
when set.is_a?(Set)
size < set.size && all? { |o| set.include?(o) }