class WordCountAnalyzer::Xhtml

Constants

XHTML_REGEX

Rubular: rubular.com/r/ENrVFMdJ8v

Attributes

string[R]

Public Class Methods

new(string:) click to toggle source
# File lib/word_count_analyzer/xhtml.rb, line 6
def initialize(string:)
  @string = string
end

Public Instance Methods

count_difference_word_boundary() click to toggle source
# File lib/word_count_analyzer/xhtml.rb, line 18
def count_difference_word_boundary
  string.split(/\s+/).size - replace.strip.split(/\s+/).size
end
includes_xhtml?() click to toggle source
# File lib/word_count_analyzer/xhtml.rb, line 10
def includes_xhtml?
  !(string !~ XHTML_REGEX)
end
occurrences() click to toggle source
# File lib/word_count_analyzer/xhtml.rb, line 22
def occurrences
  string.gsub(XHTML_REGEX, ' wsxhtmlword ').scan(/wsxhtmlword/).size / 2
end
replace() click to toggle source
# File lib/word_count_analyzer/xhtml.rb, line 14
def replace
  string.gsub(XHTML_REGEX, ' ')
end