Class: MQ::FilterDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/mq/query.rb

Overview

DSL context for building filter expressions inside select/map blocks.

All methods return a Filter that can be combined with & and |.

Examples:

String matching

MQ::Query.h2.select { contains("Feature") & starts_with("##") }

Comparison

MQ::Query.list.select { gt(5) }

Negation

MQ::Query.select { negate(contains("draft")) }

Instance Method Summary collapse

Instance Method Details

#addObject



546
# File 'lib/mq/query.rb', line 546

def add            = Filter.new("add")

#ascii_downcaseObject



542
# File 'lib/mq/query.rb', line 542

def ascii_downcase = Filter.new("ascii_downcase()")

#ascii_upcaseObject



543
# File 'lib/mq/query.rb', line 543

def ascii_upcase   = Filter.new("ascii_upcase()")

#contains(text) ⇒ Object

String matching



516
# File 'lib/mq/query.rb', line 516

def contains(text)    = Filter.new("contains(#{text.inspect})")

#emptyObject



545
# File 'lib/mq/query.rb', line 545

def empty          = Filter.new("empty")

#ends_with(text) ⇒ Object



518
# File 'lib/mq/query.rb', line 518

def ends_with(text)   = Filter.new("ends_with(#{text.inspect})")

#eq(value) ⇒ Object

Comparison operators These compare the current pipeline value against the given argument.



527
# File 'lib/mq/query.rb', line 527

def eq(value)  = Filter.new("eq(#{value.inspect})")

#gt(value) ⇒ Object



529
# File 'lib/mq/query.rb', line 529

def gt(value)  = Filter.new("gt(#{value.inspect})")

#gte(value) ⇒ Object



530
# File 'lib/mq/query.rb', line 530

def gte(value) = Filter.new("gte(#{value.inspect})")

#is_mdxObject

Type checks



535
# File 'lib/mq/query.rb', line 535

def is_mdx  = Filter.new("is_mdx()")

#is_nanObject



537
# File 'lib/mq/query.rb', line 537

def is_nan  = Filter.new("is_nan()")

#is_noneObject



536
# File 'lib/mq/query.rb', line 536

def is_none = Filter.new("is_none()")

#is_not_regex_match(pattern) ⇒ Object



523
# File 'lib/mq/query.rb', line 523

def is_not_regex_match(pattern) = Filter.new("is_not_regex_match(#{pattern.inspect})")

#is_regex_match(pattern) ⇒ Object

Regex matching



522
# File 'lib/mq/query.rb', line 522

def is_regex_match(pattern)     = Filter.new("is_regex_match(#{pattern.inspect})")

#lengthObject

String transforms usable in filter context



541
# File 'lib/mq/query.rb', line 541

def length         = Filter.new("length")

#lt(value) ⇒ Object



531
# File 'lib/mq/query.rb', line 531

def lt(value)  = Filter.new("lt(#{value.inspect})")

#lte(value) ⇒ Object



532
# File 'lib/mq/query.rb', line 532

def lte(value) = Filter.new("lte(#{value.inspect})")

#ne(value) ⇒ Object



528
# File 'lib/mq/query.rb', line 528

def ne(value)  = Filter.new("ne(#{value.inspect})")

#negate(filter) ⇒ Object

Negate a filter expression with not(). Use negate instead of not since not is a Ruby keyword.

Examples:

MQ::Query.select { negate(contains("draft")) }
# => 'select(not(contains("draft")))'


554
# File 'lib/mq/query.rb', line 554

def negate(filter) = Filter.new("not(#{filter})")

#starts_with(text) ⇒ Object



517
# File 'lib/mq/query.rb', line 517

def starts_with(text) = Filter.new("starts_with(#{text.inspect})")

#test(pattern) ⇒ Object



519
# File 'lib/mq/query.rb', line 519

def test(pattern)     = Filter.new("test(#{pattern.inspect})")

#trimObject



544
# File 'lib/mq/query.rb', line 544

def trim           = Filter.new("trim()")

#typeObject



538
# File 'lib/mq/query.rb', line 538

def type    = Filter.new("type")