class Axiom::Relation::Operation::Ungroup

A class representing an ungrouped relation

Attributes

attribute[R]

The grouped attribute

@return [Attribute::Relation]

@api private

Public Class Methods

new(operand, name) click to toggle source

Initialize an ungrouped relation

@param [Relation] operand @param [#to_sym] name

@return [undefined]

@api private

Calls superclass method Axiom::Relation::Operation::Unary::new
# File lib/axiom/relation/operation/ungroup.rb, line 27
def initialize(operand, name)
  super(operand)
  @attribute = header[name]
  @outer     = header - [attribute]
  @header    = @outer.extend(attribute.header)
end

Public Instance Methods

each() { |join| ... } click to toggle source

Iterate over each tuple in the set

@example

ungrouped = Ungroup.new(operand, name)
ungrouped.each { |tuple| ... }

@yield [tuple]

@yieldparam [Tuple] tuple

each tuple in the set

@return [self]

@api public

# File lib/axiom/relation/operation/ungroup.rb, line 48
def each
  return to_enum unless block_given?
  operand.each do |tuple|
    outer_tuple = tuple.project(@outer)
    tuple[attribute].each do |inner_tuple|
      yield outer_tuple.join(header, inner_tuple)
    end
  end
  self
end