Class: Pacer::Pipes::PathWrappingPipe

Inherits:
RubyPipe
  • Object
show all
Defined in:
lib/pacer/pipe/path_wrapping_pipe.rb

Instance Attribute Summary collapse

Attributes inherited from RubyPipe

#starts

Instance Method Summary collapse

Methods inherited from RubyPipe

#enablePath, #reset, #setStarts

Constructor Details

#initialize(graph, vertex_extensions = [], edge_extensions = []) ⇒ PathWrappingPipe

Returns a new instance of PathWrappingPipe.



7
8
9
10
11
12
13
14
15
16
# File 'lib/pacer/pipe/path_wrapping_pipe.rb', line 7

def initialize(graph, vertex_extensions = [], edge_extensions = [])
  super()
  if graph.is_a? Array
    @graph, @vertex_wrapper, @edge_wrapper = graph
  else
    @graph = graph
    @vertex_wrapper = Pacer::Wrappers::WrapperSelector.build graph, :vertex, vertex_extensions || Set[]
    @edge_wrapper = Pacer::Wrappers::WrapperSelector.build graph, :edge, edge_extensions || Set[]
  end
end

Instance Attribute Details

#edge_wrapperObject

Returns the value of attribute edge_wrapper.



5
6
7
# File 'lib/pacer/pipe/path_wrapping_pipe.rb', line 5

def edge_wrapper
  @edge_wrapper
end

#graphObject (readonly)

Returns the value of attribute graph.



4
5
6
# File 'lib/pacer/pipe/path_wrapping_pipe.rb', line 4

def graph
  @graph
end

#other_wrapperObject

Returns the value of attribute other_wrapper.



5
6
7
# File 'lib/pacer/pipe/path_wrapping_pipe.rb', line 5

def other_wrapper
  @other_wrapper
end

#vertex_wrapperObject

Returns the value of attribute vertex_wrapper.



5
6
7
# File 'lib/pacer/pipe/path_wrapping_pipe.rb', line 5

def vertex_wrapper
  @vertex_wrapper
end

Instance Method Details

#getCurrentPathObject



25
26
27
# File 'lib/pacer/pipe/path_wrapping_pipe.rb', line 25

def getCurrentPath
  starts.getCurrentPath
end

#instance(pipe, g) ⇒ Object



18
19
20
21
22
23
# File 'lib/pacer/pipe/path_wrapping_pipe.rb', line 18

def instance(pipe, g)
  g ||= graph
  p = PathWrappingPipe.new [g, vertex_wrapper, edge_wrapper]
  p.setStarts pipe
  p
end

#processNextStartObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pacer/pipe/path_wrapping_pipe.rb', line 29

def processNextStart
  path = starts.next
  path.collect do |item|
    if item.is_a? Pacer::Vertex
      vertex_wrapper.new graph, item
    elsif item.is_a? Pacer::Edge
      edge_wrapper.new graph, item
    elsif other_wrapper
      other_wrapper.new graph, item
    else
      item
    end
  end
end