Class: Prolog::Services::ReplaceContent::Splitter::Symmetric::Parts
- Inherits:
-
Object
- Object
- Prolog::Services::ReplaceContent::Splitter::Symmetric::Parts
- Defined in:
- lib/prolog/services/replace_content/splitter/symmetric.rb
Overview
Simplemindedly splits content string based on endpoints, returning bounding segments (not including substring within endpoints). Nobody should care what the marker actually is; just that it wrapps the ‘inner` value and makes the combination unique within the content.
Class Method Summary collapse
- ._marker ⇒ Object
- ._split(working, endpoints) ⇒ Object
- ._twiddle(items) ⇒ Object
- .parts(content, endpoints) ⇒ Object
Class Method Details
._marker ⇒ Object
34 35 36 |
# File 'lib/prolog/services/replace_content/splitter/symmetric.rb', line 34 def self._marker 'z|q|x' * 8 end |
._split(working, endpoints) ⇒ Object
38 39 40 41 42 |
# File 'lib/prolog/services/replace_content/splitter/symmetric.rb', line 38 def self._split(working, endpoints) marker = _marker working[endpoints] = marker working.split marker end |
._twiddle(items) ⇒ Object
44 45 46 47 48 |
# File 'lib/prolog/services/replace_content/splitter/symmetric.rb', line 44 def self._twiddle(items) return ['', ''] if items.empty? items end |
.parts(content, endpoints) ⇒ Object
30 31 32 |
# File 'lib/prolog/services/replace_content/splitter/symmetric.rb', line 30 def self.parts(content, endpoints) _twiddle(_split(content.dup, endpoints)) end |