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

Version Path
word_count_analyzer-0.0.14 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.13 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.12 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.11 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.10 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.9 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.8 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.7 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.6 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.5 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.4 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.3 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.2 lib/word_count_analyzer/number.rb
word_count_analyzer-0.0.1 lib/word_count_analyzer/number.rb