Sha256: 9fa257eb2ac86511273e525b8e4ead4544c5bfc34c8096249bf7c31a73c82fc1

Contents?: true

Size: 651 Bytes

Versions: 1

Compression:

Stored size: 651 Bytes

Contents

# typed: strict
module Repeatable
  module Expression
    class Intersection < Set
      sig { params(elements: T.any(Expression::Base, T::Array[Expression::Base])).void }
      def initialize(*elements)
        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

      sig { override.params(date: ::Date).returns(T::Boolean) }
      def include?(date)
        elements.all? { |e| e.include?(date) }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
repeatable-1.1.0 lib/repeatable/expression/intersection.rb