Class: Klue::Langcraft::DSL::ProcessDataPipeline
- Inherits:
-
Object
- Object
- Klue::Langcraft::DSL::ProcessDataPipeline
- Defined in:
- lib/klue/langcraft/dsl/process_data_pipeline.rb
Overview
ProcessDataPipeline class for executing data processing pipelines
This class is responsible for executing a series of data processing steps based on the configured processors. It manages the flow of data through the pipeline and handles the storage of results.
Instance Method Summary collapse
-
#execute(data) ⇒ Object
Execute the pipeline of processors on the input data.
-
#initialize(matcher) ⇒ ProcessDataPipeline
constructor
A new instance of ProcessDataPipeline.
-
#write_output(data, output_file) ⇒ Object
Optionally write the output to a file.
Constructor Details
#initialize(matcher) ⇒ ProcessDataPipeline
Returns a new instance of ProcessDataPipeline.
12 13 14 |
# File 'lib/klue/langcraft/dsl/process_data_pipeline.rb', line 12 def initialize(matcher) @matcher = matcher # Use the matcher to find processors end |
Instance Method Details
#execute(data) ⇒ Object
Execute the pipeline of processors on the input data
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/klue/langcraft/dsl/process_data_pipeline.rb', line 17 def execute(data) # NOTE: This is the complete data object, each processor will get a cloned version the specific data it is matched to matched_processors = @matcher.match_processors(data) matched_processors.each do |processor| processed_data = processor.build_result # Store the processed data into the result structure store_result(data, processor, processed_data) end data end |
#write_output(data, output_file) ⇒ Object
Optionally write the output to a file
32 33 34 |
# File 'lib/klue/langcraft/dsl/process_data_pipeline.rb', line 32 def write_output(data, output_file) File.write(output_file, JSON.pretty_generate(data)) end |