Class: Pacer::Transform::GatherSection::GatherSectionPipe

Inherits:
Pipes::RubyPipe
  • Object
show all
Defined in:
lib/pacer/transform/gather_section.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(visitor_pipe, graph, wrapper) ⇒ GatherSectionPipe

Returns a new instance of GatherSectionPipe.



45
46
47
48
49
50
51
52
53
54
# File 'lib/pacer/transform/gather_section.rb', line 45

def initialize(visitor_pipe, graph, wrapper)
  super()
  @collecting = []
  @graph = graph
  @wrapper = wrapper
  @visitor_pipe = visitor_pipe
  if visitor_pipe
    visitor_pipe.visitor = self
  end
end

Instance Attribute Details

#collectingObject (readonly)

Returns the value of attribute collecting.



42
43
44
# File 'lib/pacer/transform/gather_section.rb', line 42

def collecting
  @collecting
end

#collecting_pathObject (readonly)

Returns the value of attribute collecting_path.



42
43
44
# File 'lib/pacer/transform/gather_section.rb', line 42

def collecting_path
  @collecting_path
end

#getPathToHereObject (readonly)

Returns the value of attribute getPathToHere.



43
44
45
# File 'lib/pacer/transform/gather_section.rb', line 43

def getPathToHere
  @getPathToHere
end

#graphObject (readonly)

Returns the value of attribute graph.



42
43
44
# File 'lib/pacer/transform/gather_section.rb', line 42

def graph
  @graph
end

#sectionObject (readonly)

Returns the value of attribute section.



42
43
44
# File 'lib/pacer/transform/gather_section.rb', line 42

def section
  @section
end

#to_emitObject (readonly)

Returns the value of attribute to_emit.



42
43
44
# File 'lib/pacer/transform/gather_section.rb', line 42

def to_emit
  @to_emit
end

#wrapperObject (readonly)

Returns the value of attribute wrapper.



42
43
44
# File 'lib/pacer/transform/gather_section.rb', line 42

def wrapper
  @wrapper
end

Instance Method Details

#after_elementObject



89
90
91
92
93
94
95
# File 'lib/pacer/transform/gather_section.rb', line 89

def after_element
  unless collecting.empty?
    @to_emit = collecting
    @getPathToHere = collecting_path
    @collecting = []
  end
end

#emitObject



83
84
85
86
87
# File 'lib/pacer/transform/gather_section.rb', line 83

def emit
  e = to_emit
  @to_emit = nil
  e
end

#processNextStartObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/pacer/transform/gather_section.rb', line 56

def processNextStart
  if pathEnabled
    while !to_emit
      e = wrapper.new(graph, starts.next)
      collecting << e
      @collecting_path = @visitor_pipe.getCurrentPath
    end
  else
    while !to_emit
      e = wrapper.new(graph, starts.next)
      collecting << e
    end
  end
  if !to_emit
    raise EmptyPipe.instance
  else
    emit
  end
rescue EmptyPipe, java.util.NoSuchElementException
  if collecting
    @collecting = nil
    emit
  else
    raise EmptyPipe.instance
  end
end