Class: Deface::Actions::Surround

Inherits:
SurroundAction show all
Defined in:
lib/deface/actions/surround.rb

Instance Attribute Summary

Attributes inherited from ElementAction

#source_element

Instance Method Summary collapse

Methods inherited from SurroundAction

#original_placeholders, #source_element

Methods inherited from ElementAction

#initialize

Methods inherited from Action

#initialize, to_sym

Constructor Details

This class inherits a constructor from Deface::Actions::ElementAction

Instance Method Details

#execute(target_range) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/deface/actions/surround.rb', line 4

def execute(target_range)
  original_placeholders.each do |placeholder|
    start = target_range[0].clone(1)
    placeholder.replace start

    target_range[1..-1].each do |element|
      element = element.clone(1)
      start.after element
      start = element
    end
  end
  target_range.first.before(source_element)
  target_range.map(&:remove)
end

#range_compatible?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/deface/actions/surround.rb', line 19

def range_compatible?
  true
end