Class: LooseTightDictionary::StopWord

Inherits:
Object
  • Object
show all
Defined in:
lib/loose_tight_dictionary/stop_word.rb

Overview

A stop word is ignored

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#regexpObject (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

#inspectObject



15
16
17
# File 'lib/loose_tight_dictionary/stop_word.rb', line 15

def inspect
  "#<StopWord regexp=#{regexp.inspect}>"
end