Sha256: 0c08699f71bf0e938e17a4daa2ebe920199c9d7b6a6608452e540da9ac825651
Contents?: true
Size: 819 Bytes
Versions: 28
Compression:
Stored size: 819 Bytes
Contents
# frozen_string_literal: true # ReplaceAction to replace child node with code. class NodeMutation::ReplaceAction < NodeMutation::Action # Initailize a ReplaceAction. # # @param node [Node] # @param selectors [Array<Symbol|String>] used to select child nodes # @param with [String] the new code def initialize(node, *selectors, with:) super(node, with) @selectors = selectors end # The rewritten source code. # # @return [String] rewritten code. def new_code rewritten_source end private # Calculate the begin the end positions. def calculate_position @start = @selectors.map { |selector| NodeMutation.adapter.child_node_range(@node, selector).start }.min @end = @selectors.map { |selector| NodeMutation.adapter.child_node_range(@node, selector).end }.max end end
Version data entries
28 entries across 28 versions & 1 rubygems