class WordCountAnalyzer::Ellipsis

Constants

FOUR_CONSECUTIVE_REGEX

Rubular: rubular.com/r/mfdtSeuIf2

FOUR_SPACE_REGEX

Rubular: rubular.com/r/2VvZ8wRbd8

OTHER_THREE_PERIOD_REGEX
THREE_SPACE_REGEX

Rubular: rubular.com/r/YBG1dIHTRu

UNICODE_ELLIPSIS

Public Instance Methods

includes_ellipsis?(text) click to toggle source
# File lib/word_count_analyzer/ellipsis.rb, line 16
def includes_ellipsis?(text)
  !(text !~ FOUR_CONSECUTIVE_REGEX) ||
  !(text !~ THREE_SPACE_REGEX) ||
  !(text !~ FOUR_SPACE_REGEX) ||
  !(text !~ OTHER_THREE_PERIOD_REGEX) ||
  !(text !~ UNICODE_ELLIPSIS)
end
occurrences(text) click to toggle source
# File lib/word_count_analyzer/ellipsis.rb, line 32
def occurrences(text)
  count = 0
  replace(text).split(' ').map { |token| count += 1 if token.strip.eql?('wseword') }
  count
end
replace(text) click to toggle source
# File lib/word_count_analyzer/ellipsis.rb, line 24
def replace(text)
  text.gsub(FOUR_CONSECUTIVE_REGEX, ' wseword ')
        .gsub(THREE_SPACE_REGEX, ' wseword ')
        .gsub(FOUR_SPACE_REGEX, ' wseword ')
        .gsub(OTHER_THREE_PERIOD_REGEX, ' wseword ')
        .gsub(UNICODE_ELLIPSIS, ' wseword ')
end