Class: HTMLPipeline::TextFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/html_pipeline/text_filter.rb,
lib/html_pipeline/text_filter/image_filter.rb,
lib/html_pipeline/text_filter/plain_text_input_filter.rb

Direct Known Subclasses

ImageFilter, PlainTextInputFilter

Defined Under Namespace

Classes: ImageFilter, PlainTextInputFilter

Instance Attribute Summary collapse

Attributes inherited from Filter

#context, #result

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Filter

#base_url, #call, #has_ancestor?, #needs, #validate

Constructor Details

#initialize(context: {}, result: {}) ⇒ TextFilter

Returns a new instance of TextFilter.



7
8
9
# File 'lib/html_pipeline/text_filter.rb', line 7

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

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/html_pipeline/text_filter.rb', line 5

def text
  @text
end

Class Method Details

.call(text, context: {}, result: {}) ⇒ Object

Raises:

  • (TypeError)


12
13
14
15
16
17
18
# File 'lib/html_pipeline/text_filter.rb', line 12

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