Class: Repeatable::Expression::Difference

Inherits:
Base
  • Object
show all
Defined in:
lib/repeatable/expression/difference.rb

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

#initialize(included:, excluded:) ⇒ void

Parameters:



7
8
9
10
# File 'lib/repeatable/expression/difference.rb', line 7

def initialize(included:, excluded:)
  @included = included
  @excluded = excluded
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (Object)

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/repeatable/expression/difference.rb', line 18

def ==(other)
  other.is_a?(self.class) &&
    included == other.included &&
    excluded == other.excluded
end

#include?(date) ⇒ Boolean

Parameters:

  • date (::Date)

Returns:

  • (Boolean)


13
14
15
# File 'lib/repeatable/expression/difference.rb', line 13

def include?(date)
  included.include?(date) && !excluded.include?(date)
end