class Bmg::Operator::Ungroup
Attributes
attrs[R]
Public Class Methods
new(type, operand, attrs)
click to toggle source
# File lib/bmg/operator/ungroup.rb, line 6 def initialize(type, operand, attrs) @type = type @operand = operand @attrs = attrs end
Public Instance Methods
_each(tuple, attr, attrs) { |t| ... }
click to toggle source
# File lib/bmg/operator/ungroup.rb, line 35 def _each(tuple, attr, attrs, &bl) rva = tuple[attr] || [] rva.each do |rvt| t = tuple.merge(rvt).tap{|t| t.delete(attr) } if attrs.empty? yield(t) else _each(t, attrs[0], attrs[1..-1], &bl) end end end
each(&bl)
click to toggle source
# File lib/bmg/operator/ungroup.rb, line 18 def each(&bl) return to_enum unless block_given? if type.knows_keys? && type.keys.any?{|k| (k & attrs).empty? } operand.each do |tuple| _each(tuple, attrs[0], attrs[1..-1], &bl) end else with_dups = [] operand.each do |tuple| _each(tuple, attrs[0], attrs[1..-1]){|t| with_dups << t } end with_dups.uniq.each(&bl) end end
to_ast()
click to toggle source
# File lib/bmg/operator/ungroup.rb, line 47 def to_ast [ :ungroup, operand.to_ast, attrs ] end