Class: LooseTightDictionary::StopWord
- Inherits:
-
Object
- Object
- LooseTightDictionary::StopWord
- Defined in:
- lib/loose_tight_dictionary/stop_word.rb
Overview
A stop word is ignored
Instance Attribute Summary collapse
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
Instance Method Summary collapse
-
#apply!(str) ⇒ Object
Destructively remove stop words from the string.
-
#initialize(regexp_or_str) ⇒ StopWord
constructor
A new instance of StopWord.
- #inspect ⇒ Object
Constructor Details
#initialize(regexp_or_str) ⇒ StopWord
Returns a new instance of StopWord.
6 7 8 |
# File 'lib/loose_tight_dictionary/stop_word.rb', line 6 def initialize(regexp_or_str) @regexp = regexp_or_str.to_regexp end |
Instance Attribute Details
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
4 5 6 |
# File 'lib/loose_tight_dictionary/stop_word.rb', line 4 def regexp @regexp end |
Instance Method Details
#apply!(str) ⇒ Object
Destructively remove stop words from the string
11 12 13 |
# File 'lib/loose_tight_dictionary/stop_word.rb', line 11 def apply!(str) str.gsub! regexp, '' end |
#inspect ⇒ Object
15 16 17 |
# File 'lib/loose_tight_dictionary/stop_word.rb', line 15 def inspect "#<StopWord regexp=#{regexp.inspect}>" end |