Class: PoliteText::TextCleaner
- Defined in:
- lib/polite_text/text_cleaner.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #clean! ⇒ Object
-
#initialize(text) ⇒ TextCleaner
constructor
A new instance of TextCleaner.
Methods inherited from Base
#swear_words, #swear_words_list
Constructor Details
#initialize(text) ⇒ TextCleaner
Returns a new instance of TextCleaner.
5 6 7 8 9 |
# File 'lib/polite_text/text_cleaner.rb', line 5 def initialize(text) raise ArgumentError.new('The text can not be nil') if text.nil? @text = text.to_s end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/polite_text/text_cleaner.rb', line 3 def text @text end |
Instance Method Details
#clean! ⇒ Object
11 12 13 |
# File 'lib/polite_text/text_cleaner.rb', line 11 def clean! text.gsub!(swear_words, '***') || text end |