Sha256: f53e1b6ada2ed2257d2ae9b64683d91f87106361f16fb83ded39a63b5944ddb2
Contents?: true
Size: 884 Bytes
Versions: 30
Compression:
Stored size: 884 Bytes
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 each @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
30 entries across 30 versions & 1 rubygems