Module: Predicate::Neq

Includes:
DyadicComp
Defined in:
lib/predicate/nodes/neq.rb

Constant Summary

Constants included from Expr

Expr::OP_NEGATIONS

Instance Method Summary collapse

Methods included from DyadicComp

#!, #free_variables, #left, #priority, #right, #var_against_literal_value?

Methods included from Expr

#!, #&, #and_split, #attr_split, #bind, #constant_variables, #constants, #contradiction?, #dyadic_priority, #identifier?, #literal?, #opaque?, #qualify, #rename, #sexpr, #tautology?, #to_hash, #to_postgres, #to_s, #to_sequel, #unqualify, #|

Methods included from Factory

#_factor_predicate, #and, #comp, #contradiction, #empty, #from_hash, #h, #has_size, #identifier, #in, #literal, #match, #native, #not, #opaque, #or, #pg_array_empty, #pg_array_literal, #pg_array_overlaps, #placeholder, #qualified_identifier, #sexpr, #tautology, #var, #vars

Instance Method Details

#assert!(tuple, asserter = Asserter.new) ⇒ Object



13
14
15
16
17
# File 'lib/predicate/nodes/neq.rb', line 13

def assert!(tuple, asserter = Asserter.new)
  l, r = left.evaluate(tuple), right.evaluate(tuple)
  asserter.refute_equal(l, r)
  l
end

#evaluate(tuple) ⇒ Object



9
10
11
# File 'lib/predicate/nodes/neq.rb', line 9

def evaluate(tuple)
  left.evaluate(tuple) != right.evaluate(tuple)
end

#operator_symbolObject



5
6
7
# File 'lib/predicate/nodes/neq.rb', line 5

def operator_symbol
  :'!='
end

#to_hashesObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/predicate/nodes/neq.rb', line 19

def to_hashes
  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
  [ {}, hash ]
end