Sha256: 58d322389d5b2d7fcadd0447c34aca6a10c1bdec259ec41dcd72864168a3d1d3

Contents?: true

Size: 541 Bytes

Versions: 6

Compression:

Stored size: 541 Bytes

Contents

# frozen_string_literal: true

class HTMLPipeline
  class TextFilter < Filter
    attr_reader :text

    def initialize(text, context: {}, result: {})
      raise TypeError, "text must be a String" unless text.is_a?(String)

      # Ensure that this is always a string
      @text = text.respond_to?(:to_str) ? text.to_str : text.to_s
      super(context: context, result: result)
    end

    class << self
      def call(input, context: {}, result: {})
        new(input, context: context, result: result).call
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
html-pipeline-3.0.3 lib/html_pipeline/text_filter.rb
html-pipeline-3.0.2 lib/html_pipeline/text_filter.rb
html-pipeline-3.0.1 lib/html_pipeline/text_filter.rb
html-pipeline-3.0.0 lib/html_pipeline/text_filter.rb
html-pipeline-3.0.0.pre6 lib/html_pipeline/text_filter.rb
html-pipeline-3.0.0.pre5 lib/html_pipeline/text_filter.rb