class ArticleFixtureGen::Data::MtpDecoratedMarkup
Shared logic for marker tag pairs, both single MTPs and paired MTPs. This has been reworked so that the `attributes` parameter specifies the number of marker-tag pairs to be generated, by specifying the ID attributes of each MTP to be generated, working from the end of the content toward the beginning. From the standpoint of this class and its collaborators, doing so eliminates any need to differentiate between sMTPs and pMTPs, since each marker-tag pair is generated based on passed-in information.
Attributes
attributes[R]
markers[R]
Public Class Methods
call(attributes:, base_markup:)
click to toggle source
# File lib/article_fixture_gen/data/mtp_decorated_markup.rb, line 19 def self.call(attributes:, base_markup:) new(attributes).call(base_markup) end
new(attributes)
click to toggle source
# File lib/article_fixture_gen/data/mtp_decorated_markup.rb, line 31 def initialize(attributes) @attributes = attributes @markers = build_markers self end
Public Instance Methods
call(base_markup)
click to toggle source
# File lib/article_fixture_gen/data/mtp_decorated_markup.rb, line 23 def call(base_markup) parent_node = NodeFromMarkup.call base_markup add_entries(parent_node) MarkupFromNode.call parent_node end
Private Instance Methods
add_entries(parent_node)
click to toggle source
# File lib/article_fixture_gen/data/mtp_decorated_markup.rb, line 41 def add_entries(parent_node) each_entry_for(parent_node) do |target_entry, index| add_marker(parent_node, target_entry, markers[index]) end end
add_marker(parent_node, target_entry, marker)
click to toggle source
# File lib/article_fixture_gen/data/mtp_decorated_markup.rb, line 47 def add_marker(parent_node, target_entry, marker) ReplaceChildNodesUsingNewChild.call(parent_node, target_entry, marker) self end
build_markers()
click to toggle source
# File lib/article_fixture_gen/data/mtp_decorated_markup.rb, line 52 def build_markers MarkerArray.call attributes: attributes end
each_entry_for(parent_node) { |target_entry, index| ... }
click to toggle source
# File lib/article_fixture_gen/data/mtp_decorated_markup.rb, line 56 def each_entry_for(parent_node) target_entries(parent_node).each_with_index do |target_entry, index| yield target_entry, index end end
target_entries(parent_node)
click to toggle source
# File lib/article_fixture_gen/data/mtp_decorated_markup.rb, line 62 def target_entries(parent_node) BuildTargetEntryList.call(parent_node, attributes.count) end