Class: Pacer::Wrappers::WrappingPipeFunction

Inherits:
Object
  • Object
show all
Defined in:
lib/pacer/wrappers/wrapping_pipe_function.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(back, block) ⇒ WrappingPipeFunction

Returns a new instance of WrappingPipeFunction.



8
9
10
11
12
13
14
15
16
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 8

def initialize(back, block)
  @block = block
  if back
    @graph = back.graph
    @extensions = back.extensions
    element_type = back.element_type
  end
  @wrapper = WrapperSelector.build graph, element_type, extensions
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



6
7
8
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 6

def block
  @block
end

#extensionsObject (readonly)

Returns the value of attribute extensions.



6
7
8
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 6

def extensions
  @extensions
end

#graphObject (readonly)

Returns the value of attribute graph.



6
7
8
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 6

def graph
  @graph
end

#wrapperObject (readonly)

Returns the value of attribute wrapper.



6
7
8
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 6

def wrapper
  @wrapper
end

Instance Method Details

#arityObject



18
19
20
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 18

def arity
  block.arity
end

#call_with_args(element, *args) ⇒ Object



29
30
31
32
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 29

def call_with_args(element, *args)
  e = wrapper.new graph, element if element
  block.call e, *args
end

#compute(element) ⇒ Object Also known as: call



22
23
24
25
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 22

def compute(element)
  e = wrapper.new graph, element if element
  block.call e
end

#wrap_path(path) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 34

def wrap_path(path)
  path.collect do |item|
    if item.is_a? Pacer::Vertex
      wrapped = Pacer::Wrappers::VertexWrapper.new graph, item
      wrapped
    elsif item.is_a? Pacer::Edge
      wrapped = Pacer::Wrappers::EdgeWrapper.new graph, item
      wrapped
    else
      item
    end
  end
end