Sha256: d9c73399893e04d5f39842b63bce1a5e7a1b7439fe9264b09c513c2ffc03d2f5

Contents?: true

Size: 939 Bytes

Versions: 28

Compression:

Stored size: 939 Bytes

Contents

module Deface
  module Actions
    class SurroundContents < SurroundAction
      def execute(target_range)
        if target_range.length == 1
          target_element = target_range.first
          original_placeholders.each do |placeholder|
            placeholder.replace target_element.clone(1).children
          end
          target_element.children.remove
          target_element.add_child(source_element)
        else
          original_placeholders.each do |placeholder|
            start = target_range[1].clone(1)
            placeholder.replace start

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

      def range_compatible?
        true
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
deface-1.9.0 lib/deface/actions/surround_contents.rb
deface-1.8.2 lib/deface/actions/surround_contents.rb
deface-1.8.1 lib/deface/actions/surround_contents.rb
deface-1.8.0 lib/deface/actions/surround_contents.rb
deface-1.7.0 lib/deface/actions/surround_contents.rb
deface-1.6.2 lib/deface/actions/surround_contents.rb
deface-1.6.1 lib/deface/actions/surround_contents.rb
deface-1.6.0 lib/deface/actions/surround_contents.rb
deface-1.5.3 lib/deface/actions/surround_contents.rb
deface-1.5.2 lib/deface/actions/surround_contents.rb
deface-1.5.1 lib/deface/actions/surround_contents.rb
deface-1.5.0 lib/deface/actions/surround_contents.rb
deface-1.4.0 lib/deface/actions/surround_contents.rb
deface-1.3.2 lib/deface/actions/surround_contents.rb
deface-1.3.1 lib/deface/actions/surround_contents.rb
deface-1.3.0 lib/deface/actions/surround_contents.rb
deface-1.2.0 lib/deface/actions/surround_contents.rb
deface-1.1.0 lib/deface/actions/surround_contents.rb
deface-1.0.2 lib/deface/actions/surround_contents.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/deface-1.0.1/lib/deface/actions/surround_contents.rb