Sha256: e22d1218aada7fa893159d0824cb89f005212e7b3754126a63db635318af37b5
Contents?: true
Size: 1.01 KB
Versions: 17
Compression:
Stored size: 1.01 KB
Contents
module Bmg module Operator # # Restrict operator. # # Filters operand's tuples to those that meet the predicate received # at construction. # class Restrict include Operator::Unary def initialize(type, operand, predicate) @type = type @operand = operand @predicate = predicate end protected attr_reader :predicate public def bind(binding) Restrict.new(type, operand.bind(binding), predicate.bind(binding)) end def each return to_enum unless block_given? @operand.each do |tuple| yield(tuple) if @predicate.evaluate(tuple) end end def to_ast [ :restrict, operand.to_ast, predicate.sexpr ] end protected def _restrict(type, predicate) Restrict.new(type, @operand, @predicate & predicate) end protected ### inspect def args [ predicate ] end end # class Restrict end # module Operator end # module Bmg
Version data entries
17 entries across 17 versions & 1 rubygems