Class: PoliteText::TextScanner

Inherits:
Base
  • Object
show all
Defined in:
lib/polite_text/text_scanner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#swear_words, #swear_words_list

Constructor Details

#initialize(text) ⇒ TextScanner

Returns a new instance of TextScanner.

Raises:

  • (ArgumentError)


5
6
7
8
9
# File 'lib/polite_text/text_scanner.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

#textObject (readonly)

Returns the value of attribute text.



3
4
5
# File 'lib/polite_text/text_scanner.rb', line 3

def text
  @text
end

Instance Method Details

#match_swear_word?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/polite_text/text_scanner.rb', line 11

def match_swear_word?
  !@text.match?(swear_words)
end