class Bmg::Operator::Restrict
Restrict
operator.
Filters operand's tuples to those that meet the predicate received at construction.
Attributes
predicate[R]
Public Class Methods
new(type, operand, predicate)
click to toggle source
# File lib/bmg/operator/restrict.rb, line 12 def initialize(type, operand, predicate) @type = type @operand = operand @predicate = predicate end
Public Instance Methods
bind(binding)
click to toggle source
# File lib/bmg/operator/restrict.rb, line 24 def bind(binding) Restrict.new(type, operand.bind(binding), predicate.bind(binding)) end
each() { |tuple| ... }
click to toggle source
# File lib/bmg/operator/restrict.rb, line 28 def each return to_enum unless block_given? @operand.each do |tuple| yield(tuple) if @predicate.evaluate(tuple) end end
to_ast()
click to toggle source
# File lib/bmg/operator/restrict.rb, line 35 def to_ast [ :restrict, operand.to_ast, predicate.sexpr ] end
Protected Instance Methods
_restrict(type, predicate)
click to toggle source
# File lib/bmg/operator/restrict.rb, line 41 def _restrict(type, predicate) Restrict.new(type, @operand, @predicate & predicate) end