class WordCountAnalyzer::Number

Constants

NUMBER_REGEX

Rubular: rubular.com/r/OGj82uEu8d

Attributes

string[R]

Public Class Methods

new(string:) click to toggle source
# File lib/word_count_analyzer/number.rb, line 7
def initialize(string:)
  @string = string
end

Public Instance Methods

includes_number?() click to toggle source
# File lib/word_count_analyzer/number.rb, line 11
def includes_number?
  !(string !~ NUMBER_REGEX)
end
occurrences() click to toggle source
# File lib/word_count_analyzer/number.rb, line 19
def occurrences
  replace.scan(/wsnumword/).size
end
replace() click to toggle source
# File lib/word_count_analyzer/number.rb, line 15
def replace
  string.gsub(NUMBER_REGEX, ' wsnumword ')
end