class Bmg::Operator::Allbut
Allbut
operator.
Projects operand's tuples on all but given attributes, that is, removes attributes in the list. The operator takes care of removing duplicates.
Example:
[{ a: 1, b: 2 }] allbut [:b] => [{ a: 1 }]
All attributes in the butlist SHOULD be existing attributes of the input tuples.
Attributes
butlist[R]
Public Class Methods
new(type, operand, butlist)
click to toggle source
# File lib/bmg/operator/allbut.rb, line 20 def initialize(type, operand, butlist) @type = type @operand = operand @butlist = butlist end
Public Instance Methods
delete()
click to toggle source
# File lib/bmg/operator/allbut.rb, line 57 def delete operand.delete end
each() { |allbuted| ... }
click to toggle source
# File lib/bmg/operator/allbut.rb, line 32 def each return to_enum unless block_given? seen = {} @operand.each do |tuple| allbuted = tuple_allbut(tuple) unless seen.has_key?(allbuted) yield(allbuted) seen[allbuted] = true end end end
insert(arg)
click to toggle source
Calls superclass method
# File lib/bmg/operator/allbut.rb, line 44 def insert(arg) case arg when Hash then operand.insert(valid_tuple!(arg)) when Enumerable then operand.insert(arg.map{|t| valid_tuple!(t) }) else super end end
to_ast()
click to toggle source
# File lib/bmg/operator/allbut.rb, line 61 def to_ast [:allbut, operand.to_ast, butlist.dup] end
update(tuple)
click to toggle source
# File lib/bmg/operator/allbut.rb, line 53 def update(tuple) operand.update(valid_tuple!(tuple)) end