Module: RedBlocks::SetOptimizer
- Included in:
- Set
- Defined in:
- lib/red_blocks/set_optimizer.rb
Instance Method Summary collapse
-
#unset ⇒ Object
Remove intersection set(and union set) that has one set.
Instance Method Details
#unset ⇒ Object
Remove intersection set(and union set) that has one set. i.e. ‘IntersectionSet.new()` is always equal to `some_set`. So we can remove it.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/red_blocks/set_optimizer.rb', line 6 def unset case self when RedBlocks::ComposedSet if self.sets.size == 1 self.sets.first else new_set = self.dup new_set.sets = self.sets.map { |set| set.unset } new_set end when RedBlocks::Set self else raise TypeError.new("Expected a set but got #{self}") end end |