class WordManager
Attributes
exclude[R]
target[R]
Public Class Methods
new(words_text)
click to toggle source
# File lib/slack_twitter_egosa/word_manager.rb, line 6 def initialize(words_text) @target = [] @exclude = [] words_text.to_s.dup.force_encoding('utf-8').split(' ').each do |word| if word.start_with?('-') exclude << word[1..-1] else target << word end end end
Public Instance Methods
match?(text)
click to toggle source
# File lib/slack_twitter_egosa/word_manager.rb, line 26 def match?(text) match_target?(text) && unmatch_exclude?(text) end
match_exclude?(text)
click to toggle source
# File lib/slack_twitter_egosa/word_manager.rb, line 42 def match_exclude?(text) !exclude.empty? && (text =~ /#{exclude.join('|')}/i ? true : false) end
match_target?(text)
click to toggle source
# File lib/slack_twitter_egosa/word_manager.rb, line 34 def match_target?(text) !target.empty? && (text =~ /#{target.join('|')}/i ? true : false) end
query()
click to toggle source
# File lib/slack_twitter_egosa/word_manager.rb, line 19 def query [ target.join(' OR '), exclude.map { |word| "-#{word}" }.join(' ') ].join(' ').strip end
unmatch?(text)
click to toggle source
# File lib/slack_twitter_egosa/word_manager.rb, line 30 def unmatch?(text) !match?(text) end
unmatch_exclude?(text)
click to toggle source
# File lib/slack_twitter_egosa/word_manager.rb, line 46 def unmatch_exclude?(text) !match_exclude?(text) end
unmatch_target?(text)
click to toggle source
# File lib/slack_twitter_egosa/word_manager.rb, line 38 def unmatch_target?(text) !match_target?(text) end