Sha256: c726dc335249b2fbdb85527df3182c14cf6df198a586e2783a0c727baad56458
Contents?: true
Size: 595 Bytes
Versions: 14
Compression:
Stored size: 595 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(string: string).replace).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
14 entries across 14 versions & 1 rubygems