Class: Alf::Engine::Wrap

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

Overview

Wraps attributes under as a sub-tuple

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Cog

#each, #to_dot, #to_relation

Constructor Details

#initialize(operand, attributes, as, allbut) ⇒ Wrap

Creates a SetAttr instance



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

def initialize(operand, attributes, as, allbut)
  @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/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/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/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/alf/engine/wrap.rb', line 10

def operand
  @operand
end

Instance Method Details

#_eachObject



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

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