Class: Repeatable::Expression::Intersection

Inherits:
Set
  • Object
show all
Defined in:
lib/repeatable/expression/intersection.rb

Instance Attribute Summary

Attributes inherited from Set

#elements

Instance Method Summary collapse

Methods inherited from Set

#<<, #==, #to_h

Methods inherited from Base

===, #difference, #intersection, #to_h, #union

Constructor Details

#initialize(*elements) ⇒ Intersection

Returns a new instance of Intersection.



4
5
6
7
# File 'lib/repeatable/expression/intersection.rb', line 4

def initialize(*elements)
  other_intersection, not_intersection = elements.partition { |e| e.is_a?(self.class) }
  super(other_intersection.flat_map(&:elements) + not_intersection)
end

Instance Method Details

#include?(date) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/repeatable/expression/intersection.rb', line 9

def include?(date)
  elements.all? { |e| e.include?(date) }
end