class Repeatable::Expression::Set

Attributes

elements[R]

Public Class Methods

new(elements) click to toggle source
# File lib/repeatable/expression/set.rb, line 12
def initialize(elements)
  @elements = T.let(elements.flatten.uniq, T::Array[Expression::Base])
end

Public Instance Methods

<<(element) click to toggle source
# File lib/repeatable/expression/set.rb, line 17
def <<(element)
  elements << element unless elements.include?(element)
  self
end
==(other) click to toggle source
# File lib/repeatable/expression/set.rb, line 23
def ==(other)
  other.is_a?(self.class) &&
    elements.size == other.elements.size &&
    other.elements.all? { |e| elements.include?(e) }
end

Private Instance Methods

hash_value() click to toggle source
# File lib/repeatable/expression/set.rb, line 32
def hash_value
  elements.map(&:to_h)
end