class Bmg::Operator::Rxmatch
Rxmatch
operator.
Filters operand's tuples to those whose attributes match a given string or regular expression.
Constants
- DEFAULT_OPTIONS
Attributes
attrs[R]
matcher[R]
options[R]
Public Class Methods
new(type, operand, attrs, matcher, options)
click to toggle source
# File lib/bmg/operator/rxmatch.rb, line 16 def initialize(type, operand, attrs, matcher, options) @type = type @operand = operand @attrs = attrs @matcher = matcher @options = DEFAULT_OPTIONS.merge(options) end
Public Instance Methods
each() { |tuple| ... }
click to toggle source
# File lib/bmg/operator/rxmatch.rb, line 34 def each return to_enum unless block_given? @operand.each do |tuple| against = attrs.map{|a| tuple[a] }.join(" ") matcher = self.matcher unless case_sensitive? against = against.downcase matcher = matcher.downcase if matcher.is_a?(String) end yield(tuple) if against.match(matcher) end end
to_ast()
click to toggle source
# File lib/bmg/operator/rxmatch.rb, line 47 def to_ast [ :rxmatch, operand.to_ast, attrs.dup, matcher, options.dup ] end
Protected Instance Methods
_restrict(type, predicate)
click to toggle source
# File lib/bmg/operator/rxmatch.rb, line 53 def _restrict(type, predicate) @operand .restrict(predicate) .rxmatch(attrs, matcher, options) end
case_sensitive?()
click to toggle source
# File lib/bmg/operator/rxmatch.rb, line 28 def case_sensitive? !!options[:case_sensitive] end