Class: Contrast::Agent::Assess::Policy::Propagator::Center
- Defined in:
- lib/contrast/agent/assess/policy/propagator/center.rb
Overview
Propagation that results in all the tags of the source being applied to the target at its middle. The target’s preexisting tags are unaffected beyond any merging of overlapping tags.
Class Method Summary collapse
Methods inherited from Base
Class Method Details
.propagate(propagation_node, preshift, target) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/contrast/agent/assess/policy/propagator/center.rb', line 14 def propagate propagation_node, preshift, target return unless (properties = Contrast::Agent::Assess::Tracker.properties!(target)) sources = propagation_node.sources source1 = find_source(sources[0], preshift) if source1.length == target.length properties.copy_from(source1, target, 0, propagation_node.) properties. return end # find original in the target, copy tags to the new position in target original_start_index = target[0..(target.length / 2) + 1].rindex(source1) original_start_index ||= 1 properties.copy_from(source1, target, original_start_index, propagation_node.) return unless sources[1] original_end_index = original_start_index + source1.length - 1 (target, propagation_node, sources[1], preshift, original_start_index, original_end_index) end |