Sha256: be1b3d4d8e8bbcc435c6c934951c67ac93941fb785d4069d86226260be77f184
Contents?: true
Size: 500 Bytes
Versions: 1
Compression:
Stored size: 500 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 = string end def includes_number? !(string !~ NUMBER_REGEX) end def replace string.gsub(NUMBER_REGEX, ' wsnumword ') end def occurrences replace.scan(/wsnumword/).size 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/number.rb |