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