Module: Predicate::Match
- Includes:
- BinaryFunc
- Defined in:
- lib/predicate/nodes/match.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ case_sensitive: true }
Constants included from Expr
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
#case_sentitive? ⇒ Boolean
13 14 15 |
# File 'lib/predicate/nodes/match.rb', line 13 def case_sentitive? [:case_sensitive] end |
#evaluate(tuple) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/predicate/nodes/match.rb', line 17 def evaluate(tuple) l = left.evaluate(tuple) r = right.evaluate(tuple) if l.nil? or r.nil? nil elsif l.is_a?(Regexp) l =~ r.to_s elsif r.is_a?(Regexp) r =~ l.to_s elsif [:case_sensitive] l.to_s.include?(r.to_s) else l.to_s.downcase.include?(r.to_s.downcase) end end |
#options ⇒ Object
9 10 11 |
# File 'lib/predicate/nodes/match.rb', line 9 def @options ||= DEFAULT_OPTIONS.merge(self[3] || {}) end |