Sha256: 42a2d2239c26699bdd706ffdc8eae34dc35fbd826c2d07135798d26298f8e245
Contents?: true
Size: 587 Bytes
Versions: 1
Compression:
Stored size: 587 Bytes
Contents
module WordCountAnalyzer class Number # Rubular: http://rubular.com/r/OGj82uEu8d NUMBER_REGEX = /(?<=\A)\D?\d+((,|\.)*\d)*(\D?\s|\s|\.?\s|\.$)|(?<=\s)\D?\d+((,|\.)*\d)*(\D?\s|\s|\.?\s|\.$)/ attr_reader :string def initialize(string:) @string = WordCountAnalyzer::NumberedList.new(string: WordCountAnalyzer::Date.new.replace(string)).replace end def includes_number? !(string !~ NUMBER_REGEX) end def replace string.gsub(NUMBER_REGEX, ' wsnumword ') end def occurences replace.scan(/wsnumword/).size end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
word_count_analyzer-1.0.0 | lib/word_count_analyzer/number.rb |