Class: Prolog::Services::ReplaceContent::Splitter::Paired

Inherits:
Object
  • Object
show all
Defined in:
lib/prolog/services/replace_content/splitter/paired.rb

Overview

A “paired” splitter inserts an empty pair of HTML tags before the selected content, and another such empty tag pair afterwards. The tag pairs each have an ID attribute string which ends in ‘-begin’ for the tag pair before the selection, and ‘-end’ for the tag pair after the content. The default for the tag is the anchor tag (:a), though that may be changed by specifying a synbolic ‘tag` parameter (such as :span). The default text before the ’-begin’/‘-end’ text in the ID attribute strings is ‘selection’; that may similary be changed by specifying the ‘identifier` parameter to the initialiser.

Constant Summary collapse

DEFAULT_ID =
'selection'

Instance Method Summary collapse

Constructor Details

#initialize(content:, endpoints:, tag: :a, identifier: DEFAULT_ID) ⇒ Paired

Returns a new instance of Paired.



20
21
22
23
24
25
26
# File 'lib/prolog/services/replace_content/splitter/paired.rb', line 20

def initialize(content:, endpoints:, tag: :a, identifier: DEFAULT_ID)
  @content = content
  @endpoints = endpoints
  @identifier = identifier
  @tag = tag
  self
end

Instance Method Details

#innerObject



28
29
30
# File 'lib/prolog/services/replace_content/splitter/paired.rb', line 28

def inner
  content[endpoints]
end

#sourceObject



32
33
34
# File 'lib/prolog/services/replace_content/splitter/paired.rb', line 32

def source
  parts.join
end