Class: Tengine::Job::ElementSelectorNotation::PathFinder
- Inherits:
-
Object
- Object
- Tengine::Job::ElementSelectorNotation::PathFinder
- Defined in:
- lib/tengine/job/element_selector_notation.rb
Instance Method Summary collapse
-
#initialize(origin, dest) ⇒ PathFinder
constructor
A new instance of PathFinder.
- #process ⇒ Object
- #visit(element) ⇒ Object
Constructor Details
#initialize(origin, dest) ⇒ PathFinder
Returns a new instance of PathFinder.
139 140 141 |
# File 'lib/tengine/job/element_selector_notation.rb', line 139 def initialize(origin, dest) @origin, @dest = origin, dest end |
Instance Method Details
#process ⇒ Object
143 144 145 146 147 148 |
# File 'lib/tengine/job/element_selector_notation.rb', line 143 def process @routes = [] @current_route = [] @origin.accept_visitor(self) @routes.select{|route| route.last == @dest} end |
#visit(element) ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/tengine/job/element_selector_notation.rb', line 150 def visit(element) @current_route << element if element.is_a?(Tengine::Job::Edge) element.destination.accept_visitor(self) else @routes << @current_route.dup return if element == @dest element.next_edges.each do |edge| bak = @current_route.dup begin edge.accept_visitor(self) ensure @current_route = bak end end end end |