Class: Alf::Engine::Ungroup

Inherits:
Object
  • Object
show all
Includes:
Cog
Defined in:
lib/alf/engine/ungroup.rb

Constant Summary

Constants included from Cog

Cog::EMPTY_CHILDREN, Cog::EMPTY_OPTIONS

Instance Attribute Summary collapse

Attributes included from Compiler::Cog

#compiler, #expr

Instance Method Summary collapse

Methods included from Cog

#children, #each, #options, #to_s

Methods included from Compiler::Cog

#cog_orders, #orderedby?, #relation_type, #to_ascii_tree, #to_cog, #to_relation

Constructor Details

#initialize(operand, attribute, expr = nil, compiler = nil) ⇒ Ungroup

Creates a Ungroup instance


13
14
15
16
17
# File 'lib/alf/engine/ungroup.rb', line 13

def initialize(operand, attribute, expr = nil, compiler = nil)
  super(expr, compiler)
  @operand = operand
  @attribute = attribute
end

Instance Attribute Details

#attributeAttrName (readonly)


10
11
12
# File 'lib/alf/engine/ungroup.rb', line 10

def attribute
  @attribute
end

#operandEnumerable (readonly)


7
8
9
# File 'lib/alf/engine/ungroup.rb', line 7

def operand
  @operand
end

Instance Method Details

#_eachObject


20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/alf/engine/ungroup.rb', line 20

def _each
  operand.each do |tuple|
    tuple = tuple.dup
    tuple = tuple.to_hash unless tuple.is_a?(Hash)
    unless rva = tuple.delete(@attribute)
      raise "No such RVA `#{@attribute}` on #{tuple.inspect}"
    end
    rva.each do |subtuple|
      subtuple = symbolize(subtuple)
      yield tuple.merge(subtuple)
    end
  end
end

#argumentsObject


34
35
36
# File 'lib/alf/engine/ungroup.rb', line 34

def arguments
  [ attribute ]
end