Class: Alf::Engine::Wrap

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

Overview

Wraps attributes under as a sub-tuple

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, attributes, as, allbut, expr = nil, compiler = nil) ⇒ Wrap

Creates a SetAttr instance


22
23
24
25
26
27
28
# File 'lib/alf/engine/wrap.rb', line 22

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

Instance Attribute Details

#allbutBoolean (readonly)

Returns Allbut wrapping?

Returns:

  • (Boolean)

    Allbut wrapping?


19
20
21
# File 'lib/alf/engine/wrap.rb', line 19

def allbut
  @allbut
end

#asAttrName (readonly)

Returns Name of the introduced wrapped attribute

Returns:

  • (AttrName)

    Name of the introduced wrapped attribute


16
17
18
# File 'lib/alf/engine/wrap.rb', line 16

def as
  @as
end

#attributesAttrList (readonly)

Returns Attributes to wrap

Returns:

  • (AttrList)

    Attributes to wrap


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

def attributes
  @attributes
end

#operandEnumerable (readonly)

Returns The operand

Returns:

  • (Enumerable)

    The operand


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

def operand
  @operand
end

Instance Method Details

#_eachObject


31
32
33
34
35
36
37
# File 'lib/alf/engine/wrap.rb', line 31

def _each
  operand.each do |tuple|
    rest, key = @attributes.split_tuple(tuple, @allbut)
    key[@as] = rest
    yield key
  end
end

#argumentsObject


39
40
41
# File 'lib/alf/engine/wrap.rb', line 39

def arguments
  [ attribute ]
end