Module: Enumerable

Defined in:
lib/pg-verify/core/extensions/enumerable_extensions.rb

Instance Method Summary collapse

Instance Method Details

#powersetObject



3
4
5
6
7
8
9
10
11
# File 'lib/pg-verify/core/extensions/enumerable_extensions.rb', line 3

def powerset
    array = self.to_a()
    ret = Enumerator.new {|ps|
        array.size.times {|n|
            array.combination(n).each(&ps.method(:yield))
        }
    }
    return ret.to_a + [array]
end

#subset?(other) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/pg-verify/core/extensions/enumerable_extensions.rb', line 13

def subset?(other)
    other = other.to_a()
    array = self.to_a()
    return other.all? { |item| array.include?(item) }
end