Class: Deface::Actions::ReplaceContents

Inherits:
ElementAction show all
Defined in:
lib/deface/actions/replace_contents.rb

Instance Attribute Summary

Attributes inherited from ElementAction

#source_element

Instance Method Summary collapse

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
# File 'lib/deface/actions/replace_contents.rb', line 4

def execute(target_range)
  if target_range.length == 1
    target_range.first.children.remove
    target_range.first.add_child(source_element)
  else
    target_range[1..-2].map(&:remove)
    target_range.first.after(source_element)
  end
end

#range_compatible?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/deface/actions/replace_contents.rb', line 14

def range_compatible?
  true
end