Class: Texter::RunPreprocessorsOnText

Inherits:
Object
  • Object
show all
Includes:
CallableClass
Defined in:
app/lib/texter/run_preprocessors_on_text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, options = {}) ⇒ RunPreprocessorsOnText

Returns a new instance of RunPreprocessorsOnText.

Parameters:

  • text (Texter::Text)
  • options (Hash) (defaults to: {})

    (:force => true to force processing)



9
10
11
12
# File 'app/lib/texter/run_preprocessors_on_text.rb', line 9

def initialize(text, options = {})
  @text = text
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'app/lib/texter/run_preprocessors_on_text.rb', line 5

def options
  @options
end

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'app/lib/texter/run_preprocessors_on_text.rb', line 5

def text
  @text
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
# File 'app/lib/texter/run_preprocessors_on_text.rb', line 14

def call
  attributes.each do |attr|
    body = text.send(attr)
    processed = Texter.preprocessors.inject(body) { |memo, preprocessor| Texter.find_preprocessor(preprocessor).call(memo) }
    text.send "#{attr}=", processed
  end
end