Class: Pacer::Transform::Payload::PayloadPipe

Inherits:
Pipes::RubyPipe
  • Object
show all
Defined in:
lib/pacer/transform/payload.rb

Instance Attribute Summary collapse

Attributes inherited from Pipes::RubyPipe

#starts

Instance Method Summary collapse

Methods inherited from Pipes::RubyPipe

#enablePath, #reset, #setStarts

Constructor Details

#initialize(route, block) ⇒ PayloadPipe

Returns a new instance of PayloadPipe.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pacer/transform/payload.rb', line 24

def initialize(route, block)
  super()
  if route.element_type == :edge
    @wrapper = Pacer::Payload::Edge
  elsif route.element_type == :vertex
    @wrapper = Pacer::Payload::Vertex
  else
    fail Pacer::ClientError, 'Can not use PayloadPipe on non-element data'
  end
  block ||= proc { |el| nil }
  @block = Pacer::Wrappers::WrappingPipeFunction.new route, block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



22
23
24
# File 'lib/pacer/transform/payload.rb', line 22

def block
  @block
end

#wrapperObject (readonly)

Returns the value of attribute wrapper.



22
23
24
# File 'lib/pacer/transform/payload.rb', line 22

def wrapper
  @wrapper
end

Instance Method Details

#getPathToHereObject



42
43
44
45
46
47
48
# File 'lib/pacer/transform/payload.rb', line 42

def getPathToHere
  path = super
  i = path.size - 1
  path.remove path.size - 1 if i >= 0
  path.add currentEnd
  path
end

#processNextStartObject



37
38
39
40
# File 'lib/pacer/transform/payload.rb', line 37

def processNextStart
  el = starts.next
  @wrapper.new el, block.call(el)
end