Sha256: 50976128673c478eac6ecf8ecc47327d47e93787a3ca125c75ed47c7a5b8b094
Contents?: true
Size: 554 Bytes
Versions: 1
Compression:
Stored size: 554 Bytes
Contents
module WordCountAnalyzer class Xhtml # Rubular: http://rubular.com/r/ENrVFMdJ8v XHTML_REGEX = /<\/?[^>]*>/ attr_reader :string def initialize(string:) @string = string end def includes_xhtml? !(string !~ XHTML_REGEX) end def replace string.gsub(XHTML_REGEX, ' ') end def count_difference_word_boundary string.split(/\s+/).size - replace.strip.split(/\s+/).size end def occurrences string.gsub(XHTML_REGEX, ' wsxhtmlword ').scan(/wsxhtmlword/).size / 2 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
word_count_analyzer-1.0.1 | lib/word_count_analyzer/xhtml.rb |