diff --git a/lib/set.rb b/lib/set.rb index caf80aa930..05eb3ffb2a 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -237,7 +237,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) } @@ -250,7 +250,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) } @@ -263,7 +263,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) } @@ -276,7 +276,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) }