Class: Uniword::Batch::ProcessingStage
- Inherits:
-
Object
- Object
- Uniword::Batch::ProcessingStage
- Defined in:
- lib/uniword/batch/processing_stage.rb
Overview
Base class for batch processing pipeline stages.
Responsibility: Define the interface for processing pipeline stages. Each stage performs one specific transformation or validation on a document.
Follows Single Responsibility Principle - one stage does one transformation. Follows Open/Closed Principle - new stages can be added without modifying this class.
Direct Known Subclasses
CompressImagesStage, ConvertFormatStage, NormalizeStylesStage, QualityCheckStage, UpdateMetadataStage, ValidateLinksStage
Instance Attribute Summary collapse
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#description ⇒ String
Get stage description (for logging and reporting).
-
#enabled? ⇒ Boolean
Check if stage is enabled.
-
#initialize(options = {}) ⇒ ProcessingStage
constructor
Initialize processing stage.
-
#name ⇒ String
Get stage name (used for identification and logging).
-
#process(document, context = {}) ⇒ Document
Process a document through this stage.
Constructor Details
#initialize(options = {}) ⇒ ProcessingStage
Initialize processing stage
33 34 35 36 |
# File 'lib/uniword/batch/processing_stage.rb', line 33 def initialize( = {}) @options = || {} @enabled = @options.fetch(:enabled, true) end |
Instance Attribute Details
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
27 28 29 |
# File 'lib/uniword/batch/processing_stage.rb', line 27 def enabled @enabled end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
27 28 29 |
# File 'lib/uniword/batch/processing_stage.rb', line 27 def @options end |
Instance Method Details
#description ⇒ String
Get stage description (for logging and reporting)
69 70 71 |
# File 'lib/uniword/batch/processing_stage.rb', line 69 def description "#{name} stage" end |
#enabled? ⇒ Boolean
Check if stage is enabled
41 42 43 |
# File 'lib/uniword/batch/processing_stage.rb', line 41 def enabled? @enabled end |
#name ⇒ String
Get stage name (used for identification and logging)
58 59 60 61 62 63 64 |
# File 'lib/uniword/batch/processing_stage.rb', line 58 def name self.class.name.split("::").last .gsub(/Stage$/, "") .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .downcase end |
#process(document, context = {}) ⇒ Document
Process a document through this stage
51 52 53 |
# File 'lib/uniword/batch/processing_stage.rb', line 51 def process(document, context = {}) raise NotImplementedError, "#{self.class} must implement #process" end |