Class: Klue::Langcraft::DSL::ProcessMatcher
- Inherits:
-
Object
- Object
- Klue::Langcraft::DSL::ProcessMatcher
- Defined in:
- lib/klue/langcraft/dsl/process_matcher.rb
Overview
ProcessMatcher class for matching processors to input nodes
This class is responsible for traversing input nodes and finding the appropriate processor for each node based on the configured processor rules.
Instance Method Summary collapse
-
#initialize(processor_config = ProcessorConfigDefault) ⇒ ProcessMatcher
constructor
A new instance of ProcessMatcher.
- #match_processors(nodes) ⇒ Object
Constructor Details
#initialize(processor_config = ProcessorConfigDefault) ⇒ ProcessMatcher
Returns a new instance of ProcessMatcher.
12 13 14 |
# File 'lib/klue/langcraft/dsl/process_matcher.rb', line 12 def initialize(processor_config = ProcessorConfigDefault) @processor_config = processor_config end |
Instance Method Details
#match_processors(nodes) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/klue/langcraft/dsl/process_matcher.rb', line 16 def match_processors(nodes) matched_processors = [] traverse_nodes(nodes) do |key, value| processor_class = find_processor_for(key, value) if processor_class if value.is_a?(Array) # If the value is an array, instantiate a processor for each element value.each do |element| matched_processors << processor_class.new(element, key) end else matched_processors << processor_class.new(value, key) end end end matched_processors end |