Sha256: 1e59c855c7b889a241ee63fba12c265e14bc13f48a241a802ac7e7615afce0bd

Contents?: true

Size: 504 Bytes

Versions: 1

Compression:

Stored size: 504 Bytes

Contents

# frozen_string_literal: true

class HTMLPipeline
  class TextFilter < Filter
    attr_reader :text

    def initialize(context: {}, result: {})
      super
    end

    class << self
      def call(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
        new(context: context, result: result).call(text)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
html-pipeline-3.2.1 lib/html_pipeline/text_filter.rb