Class: Prolog::Services::ReplaceContent::Splitter::Symmetric::Parts

Inherits:
Object
  • Object
show all
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

Class Method Details

._markerObject



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