Class: Alf::Engine::InferHeading

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

Overview

Infers the heading of the iterated relation.

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

#arguments, #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, expr = nil, compiler = nil) ⇒ InferHeading

Returns a new instance of InferHeading


12
13
14
15
# File 'lib/alf/engine/infer_heading.rb', line 12

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

Instance Attribute Details

#operandEnumerable (readonly)

Returns The operand

Returns:

  • (Enumerable)

    The operand


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

def operand
  @operand
end

Instance Method Details

#_each {|heading.to_h| ... } ⇒ Object

Yields:

  • (heading.to_h)

17
18
19
20
# File 'lib/alf/engine/infer_heading.rb', line 17

def _each
  heading = operand.inject(Alf::Heading::EMPTY){|h,t| h + heading(t) }
  yield(heading.to_h)
end