Class: Pacer::Transform::PathTree::PathTreePipe

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

Instance Attribute Summary

Attributes inherited from Pipes::RubyPipe

#starts

Instance Method Summary collapse

Methods inherited from Pipes::RubyPipe

#enablePath, #reset, #setStarts

Constructor Details

#initialize(compare = nil) ⇒ PathTreePipe

Returns a new instance of PathTreePipe.



37
38
39
40
41
42
# File 'lib/pacer/transform/path_tree.rb', line 37

def initialize(compare = nil)
  super()
  self.building_path = nil
  self.prev_path = nil
  self.compare = compare || proc { |a, b| a == b }
end

Instance Method Details

#processNextStartObject

NOTE: doesn’t handle variable length paths yet…



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/pacer/transform/path_tree.rb', line 45

def processNextStart()
  while true
    path = starts.next
    if building_path
      if compare.call path.first, building_path.first
        add_path path
      else
        return next_path(path)
      end
    else
      next_path(path)
    end
  end
rescue Pacer::EmptyPipe, java.util.NoSuchElementException
  if building_path
    r = building_path
    self.building_path = nil
    r
  else
    raise EmptyPipe.instance
  end
end