Class: PrepareTextService

Inherits:
Object
  • Object
show all
Defined in:
lib/services/prepare_text_service.rb

Constant Summary collapse

SPECIAL_CHARACTERS =
/([•|—|–|\-|\’|,|?|!|^|\r|°|“|”|...|\u00a0|«|»|…|\\|\/|!|?|\"|\'|\[|\]|\(|\)|\]|<|>|=|+|%|$|&|#|;|*|:|}|{|`])/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ PrepareTextService

Returns a new instance of PrepareTextService.



8
9
10
11
# File 'lib/services/prepare_text_service.rb', line 8

def initialize(text)
  @text = text
  @prepared_text = text.dup
end

Instance Attribute Details

#prepared_textObject

Returns the value of attribute prepared_text.



6
7
8
# File 'lib/services/prepare_text_service.rb', line 6

def prepared_text
  @prepared_text
end

#textObject

Returns the value of attribute text.



6
7
8
# File 'lib/services/prepare_text_service.rb', line 6

def text
  @text
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
# File 'lib/services/prepare_text_service.rb', line 13

def call
  downcase_text!
  remove_special_characters!
  split_text!
  wordify_numbers!

  prepared_text
end