Class: Coelacanth::Extractor::Preprocessor

Inherits:
Object
  • Object
show all
Defined in:
lib/coelacanth/extractor/preprocessor.rb

Overview

Applies pre-processing steps before running the main extraction pipeline.

Defined Under Namespace

Modules: Preprocessors

Instance Method Summary collapse

Constructor Details

#initialize(preprocessors: default_preprocessors) ⇒ Preprocessor

Returns a new instance of Preprocessor.



14
15
16
# File 'lib/coelacanth/extractor/preprocessor.rb', line 14

def initialize(preprocessors: default_preprocessors)
  @preprocessors = preprocessors
end

Instance Method Details

#call(html:, url: nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/coelacanth/extractor/preprocessor.rb', line 18

def call(html:, url: nil)
  return html if url.nil?

  @preprocessors.each do |preprocessor|
    processed = preprocessor.call(html: html, url: url)
    return processed if processed
  end

  html
end