Class: Roast::Workflow::StepFinder
- Inherits:
-
Object
- Object
- Roast::Workflow::StepFinder
- Defined in:
- lib/roast/workflow/step_finder.rb
Overview
Finds step indices within workflow step arrays Handles various step formats: strings, hashes, parallel arrays
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Class Method Summary collapse
Instance Method Summary collapse
-
#extract_name(step) ⇒ String, Array
Extract the name from a step definition.
-
#find_index(step_name, steps_array = nil) ⇒ Integer?
Find the index of a step in the workflow steps array.
-
#initialize(steps = nil) ⇒ StepFinder
constructor
A new instance of StepFinder.
Constructor Details
#initialize(steps = nil) ⇒ StepFinder
Returns a new instance of StepFinder.
10 11 12 |
# File 'lib/roast/workflow/step_finder.rb', line 10 def initialize(steps = nil) @steps = steps || [] end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
8 9 10 |
# File 'lib/roast/workflow/step_finder.rb', line 8 def steps @steps end |
Class Method Details
.find_index(steps_array, step_name) ⇒ Object
15 16 17 |
# File 'lib/roast/workflow/step_finder.rb', line 15 def find_index(steps_array, step_name) new(steps_array).find_index(step_name) end |
Instance Method Details
#extract_name(step) ⇒ String, Array
Extract the name from a step definition
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/roast/workflow/step_finder.rb', line 37 def extract_name(step) case step when String step when Hash step.keys.first when Array # For arrays, extract names from all contained steps step.map { |s| extract_name(s) } end end |
#find_index(step_name, steps_array = nil) ⇒ Integer?
Find the index of a step in the workflow steps array
24 25 26 27 28 29 30 31 32 |
# File 'lib/roast/workflow/step_finder.rb', line 24 def find_index(step_name, steps_array = nil) search_array = steps_array || @steps # First, try direct search index = find_by_direct_search(search_array, step_name) return index if index # Fall back to extracted name search find_by_extracted_name(search_array, step_name) end |