Sha256: d31542c1138bbde24403562e42859347ccea61d9187077472494bf8b205e38ee

Contents?: true

Size: 349 Bytes

Versions: 4

Compression:

Stored size: 349 Bytes

Contents

# frozen_string_literal: true

module AutoHtml
  # Applies collection of filters to a text
  class Pipeline
    def initialize(*filters)
      @filters = filters.flatten
    end

    def call(text)
      return '' if text.nil? || text.empty?

      @filters.inject(text) do |content, filter|
        filter.call(content)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
auto_html-2.2.0 lib/auto_html/pipeline.rb
auto_html-2.1.1 lib/auto_html/pipeline.rb
auto_html-2.1.0 lib/auto_html/pipeline.rb
auto_html-2.0.2 lib/auto_html/pipeline.rb