Class: Repeatable::Expression::Union
- Defined in:
- lib/repeatable/expression/union.rb
Instance Attribute Summary
Attributes inherited from Set
Instance Method Summary collapse
- #include?(date) ⇒ Boolean
-
#initialize(*elements) ⇒ Union
constructor
A new instance of Union.
Methods inherited from Set
Methods inherited from Base
===, #deconstruct_keys, #difference, #intersection, #to_h, #union
Constructor Details
#initialize(*elements) ⇒ Union
Returns a new instance of Union.
7 8 9 10 11 12 |
# File 'lib/repeatable/expression/union.rb', line 7 def initialize(*elements) elements = Array(elements).flatten other_unions, not_unions = elements.partition { |e| e.is_a?(self.class) } other_unions = T.cast(other_unions, T::Array[Expression::Union]) super(other_unions.flat_map(&:elements).concat(not_unions)) end |
Instance Method Details
#include?(date) ⇒ Boolean
15 16 17 |
# File 'lib/repeatable/expression/union.rb', line 15 def include?(date) elements.any? { |e| e.include?(date) } end |