Sha256: a363e33c1249f6e050129c2da15c117f8f6be09a54bbe06398016c93a3943699

Contents?: true

Size: 539 Bytes

Versions: 3

Compression:

Stored size: 539 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

3 entries across 3 versions & 1 rubygems

Version Path
html-pipeline-3.0.0.pre3 lib/html_pipeline/text_filter.rb
html-pipeline-3.0.0.pre2 lib/html_pipeline/text_filter.rb
html-pipeline-3.0.0.pre1 lib/html_pipeline/text_filter.rb