Class: WordCountAnalyzer::Punctuation
- Inherits:
-
Object
- Object
- WordCountAnalyzer::Punctuation
- Defined in:
- lib/word_count_analyzer/punctuation.rb
Constant Summary collapse
- DOTTED_LINE_REGEX =
Rubular: rubular.com/r/ZVBsZVkiqC
/…{2,}|\.{5,}/- DASHED_LINE_REGEX =
Rubular: rubular.com/r/RjZ7qi0uFf
/(?<=\s)-{2,}(\s|$)|\A-{2,}(?=(\s|$))/- UNDERSCORE_REGEX =
Rubular: rubular.com/r/hNofimZwdh
/(?<=\s)_{2,}(\s|$)|\A_{2,}(?=(\s|$))/- STRAY_PUNCTUATION_REGEX =
Rubular: rubular.com/r/FexKxGUuIe
/(?<=\s|\A)[[:punct:]](?=(\s|$))|(?<=\s|\A)\|(?=(\s|$))/
Instance Attribute Summary collapse
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
- #dashed_line_ocurrances ⇒ Object
- #dotted_line_ocurrances ⇒ Object
-
#initialize(string:) ⇒ Punctuation
constructor
A new instance of Punctuation.
- #replace_dashed_line ⇒ Object
- #replace_dotted_line ⇒ Object
- #replace_stray_punctuation ⇒ Object
- #replace_underscore ⇒ Object
- #stray_punctuation_occurences ⇒ Object
- #underscore_ocurrances ⇒ Object
Constructor Details
#initialize(string:) ⇒ Punctuation
Returns a new instance of Punctuation.
16 17 18 |
# File 'lib/word_count_analyzer/punctuation.rb', line 16 def initialize(string:) @string = string end |
Instance Attribute Details
#string ⇒ Object (readonly)
Returns the value of attribute string.
15 16 17 |
# File 'lib/word_count_analyzer/punctuation.rb', line 15 def string @string end |
Instance Method Details
#dashed_line_ocurrances ⇒ Object
24 25 26 |
# File 'lib/word_count_analyzer/punctuation.rb', line 24 def dashed_line_ocurrances string.scan(DASHED_LINE_REGEX).size end |
#dotted_line_ocurrances ⇒ Object
20 21 22 |
# File 'lib/word_count_analyzer/punctuation.rb', line 20 def dotted_line_ocurrances string.scan(DOTTED_LINE_REGEX).size end |
#replace_dashed_line ⇒ Object
40 41 42 |
# File 'lib/word_count_analyzer/punctuation.rb', line 40 def replace_dashed_line string.gsub(DASHED_LINE_REGEX, '') end |
#replace_dotted_line ⇒ Object
36 37 38 |
# File 'lib/word_count_analyzer/punctuation.rb', line 36 def replace_dotted_line string.gsub(DOTTED_LINE_REGEX, '') end |
#replace_stray_punctuation ⇒ Object
48 49 50 |
# File 'lib/word_count_analyzer/punctuation.rb', line 48 def replace_stray_punctuation string.gsub(STRAY_PUNCTUATION_REGEX, '') end |
#replace_underscore ⇒ Object
44 45 46 |
# File 'lib/word_count_analyzer/punctuation.rb', line 44 def replace_underscore string.gsub(UNDERSCORE_REGEX, '') end |
#stray_punctuation_occurences ⇒ Object
32 33 34 |
# File 'lib/word_count_analyzer/punctuation.rb', line 32 def stray_punctuation_occurences string.scan(STRAY_PUNCTUATION_REGEX).size end |
#underscore_ocurrances ⇒ Object
28 29 30 |
# File 'lib/word_count_analyzer/punctuation.rb', line 28 def underscore_ocurrances string.scan(UNDERSCORE_REGEX).size end |