Module: Predicate::HasSize

Includes:
BinaryFunc
Defined in:
lib/predicate/nodes/has_size.rb

Constant Summary

Constants included from Expr

Expr::OP_NEGATIONS

Instance Method Summary collapse

Methods included from BinaryFunc

#free_variables, #left, #priority, #right

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

#evaluate(tuple) ⇒ Object

Raises:



5
6
7
8
9
10
11
# File 'lib/predicate/nodes/has_size.rb', line 5

def evaluate(tuple)
  l, r = left.evaluate(tuple), right.evaluate(tuple)
  r = r..r if r.is_a?(Integer)
  raise Error, "Expected Range, got #{r}" unless r.is_a?(Range)
  raise Error, "Expected #{l} to respond to :size" unless l.respond_to?(:size)
  r === l.size
end