module Predicate::Eq

Public Instance Methods

&(other) click to toggle source
Calls superclass method
# File lib/predicate/nodes/eq.rb, line 9
def &(other)
  return super unless free_variables == other.free_variables
  case other
  when Eq
    return self if constants == other.constants
    return contradiction
  when In
    return super unless var_against_literal_value? && other.var_against_literal_value?
    mine, hers = self.right.value, other.right.value
    return self if hers.include?(mine)
    contradiction
  else
    super
  end
rescue NotSupportedError
  super
end
constant_variables() click to toggle source
# File lib/predicate/nodes/eq.rb, line 27
def constant_variables
  fv = free_variables
  fv.size == 1 ? fv : []
end
constants() click to toggle source
# File lib/predicate/nodes/eq.rb, line 32
def constants
  left, right = sexpr(self.left), sexpr(self.right)
  if left.identifier? && right.literal? && !right.has_placeholder?
    { left.name => right.value }
  elsif right.identifier? && left.literal? && !left.has_placeholder?
    { right.name => left.value }
  else
    {}
  end
end
dyadic_priority() click to toggle source
# File lib/predicate/nodes/eq.rb, line 43
def dyadic_priority; 900; end
evaluate(tuple) click to toggle source
# File lib/predicate/nodes/eq.rb, line 45
def evaluate(tuple)
  left.evaluate(tuple) == right.evaluate(tuple)
end
operator_symbol() click to toggle source
# File lib/predicate/nodes/eq.rb, line 5
def operator_symbol
  :==
end
to_hash() click to toggle source
Calls superclass method
# File lib/predicate/nodes/eq.rb, line 49
def to_hash
  if left.identifier? && right.literal? && !right.has_placeholder?
    { left.name => right.value }
  elsif right.identifier? && left.literal? && !left.has_placeholder?
    { right.name => left.value }
  else
    super
  end
end