class Axiom::Relation::Operation::Group
A class representing a grouped relation
Attributes
attribute[R]
The grouped attribute
@return [Attribute::Relation]
@api private
Public Class Methods
new(operand, name, attributes)
click to toggle source
Initialize a grouped relation
@param [Relation] operand @param [#to_sym] name @param [Enumerable<Axiom::Attribute>] attributes
@return [undefined]
@api private
Calls superclass method
Axiom::Relation::Operation::Unary::new
# File lib/axiom/relation/operation/group.rb, line 28 def initialize(operand, name, attributes) super(operand) inner = header.project(attributes) @outer = header - inner @attribute = Attribute::Relation.new(name, header: inner) @header = @outer.extend(attribute) end
Public Instance Methods
each() { |extend(header, [inner_relation])| ... }
click to toggle source
Iterate over each tuple in the set
@example
grouped = Group.new(operand, name, attributes) grouped.each { |tuple| ... }
@yield [tuple]
@yieldparam [Tuple] tuple
each tuple in the set
@return [self]
@api public
# File lib/axiom/relation/operation/group.rb, line 50 def each return to_enum unless block_given? build_index.each do |outer_tuple, inner_tuples| inner_relation = attribute.new_relation(inner_tuples) yield outer_tuple.extend(header, [inner_relation]) end self end
Private Instance Methods
build_index()
click to toggle source
Build an index using every tuple in the operand
@return [Index]
@api private
# File lib/axiom/relation/operation/group.rb, line 66 def build_index Index.new(@outer, @attribute.header).merge(operand) end