Class: Pacer::Wrappers::PathWrappingPipeFunction

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(back, block) ⇒ PathWrappingPipeFunction

Returns a new instance of PathWrappingPipeFunction.



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

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

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



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

def block
  @block
end

#graphObject (readonly)

Returns the value of attribute graph.



6
7
8
# File 'lib/pacer/wrappers/path_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/path_wrapping_pipe_function.rb', line 6

def wrapper
  @wrapper
end

Instance Method Details

#arityObject



16
17
18
# File 'lib/pacer/wrappers/path_wrapping_pipe_function.rb', line 16

def arity
  block.arity
end

#call_with_args(element, *args) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/pacer/wrappers/path_wrapping_pipe_function.rb', line 33

def call_with_args(element, *args)
  if path.first.is_a? Pacer::Wrappers::ElementWrapper
    block.call path, *args
  else
    p = path.map do |element|
      wrapper.new graph, element
    end
    block.call p, *args
  end
end

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



20
21
22
23
24
25
26
27
28
29
# File 'lib/pacer/wrappers/path_wrapping_pipe_function.rb', line 20

def compute(path)
  if path.first.is_a? Pacer::Wrappers::ElementWrapper
    block.call path
  else
    p = path.map do |element|
      wrapper.new graph, element
    end
    block.call p
  end
end