Class: WordCountAnalyzer::Number
- Inherits:
-
Object
- Object
- WordCountAnalyzer::Number
- Defined in:
- lib/word_count_analyzer/number.rb
Constant Summary collapse
- NUMBER_REGEX =
Rubular: rubular.com/r/OGj82uEu8d
/(?<=\A)\D?\d+((,|\.)*\d)*(\D?\s|\s|\.?\s|\.$)|(?<=\s)\D?\d+((,|\.)*\d)*(\D?\s|\s|\.?\s|\.$)/
Instance Attribute Summary collapse
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
- #includes_number? ⇒ Boolean
-
#initialize(string:) ⇒ Number
constructor
A new instance of Number.
- #occurences ⇒ Object
- #replace ⇒ Object
Constructor Details
#initialize(string:) ⇒ Number
Returns a new instance of Number.
7 8 9 |
# File 'lib/word_count_analyzer/number.rb', line 7 def initialize(string:) @string = WordCountAnalyzer::NumberedList.new(string: WordCountAnalyzer::Date.new.replace(string)).replace end |
Instance Attribute Details
#string ⇒ Object (readonly)
Returns the value of attribute string.
6 7 8 |
# File 'lib/word_count_analyzer/number.rb', line 6 def string @string end |
Instance Method Details
#includes_number? ⇒ Boolean
11 12 13 |
# File 'lib/word_count_analyzer/number.rb', line 11 def includes_number? !(string !~ NUMBER_REGEX) end |
#occurences ⇒ Object
19 20 21 |
# File 'lib/word_count_analyzer/number.rb', line 19 def occurences replace.scan(/wsnumword/).size end |
#replace ⇒ Object
15 16 17 |
# File 'lib/word_count_analyzer/number.rb', line 15 def replace string.gsub(NUMBER_REGEX, ' wsnumword ') end |