demarches-normaliennes/app/models/logic/eq.rb

19 lines
434 B
Ruby
Raw Normal View History

2022-06-09 13:48:45 +02:00
class Logic::Eq < Logic::BinaryOperator
def operation = :==
def errors(stable_ids = [])
errors = []
if !Logic.compatible_type?(@left, @right)
errors += ["les types sont incompatibles : #{self}"]
end
errors + @left.errors(stable_ids) + @right.errors(stable_ids)
end
def ==(other)
self.class == other.class &&
[@left, @right].permutation.any? { |p| p == [other.left, other.right] }
end
end