Sha256: 610915777babe875942c760257895b4376507d6a1336f57c5d1469f81d3bab13
Contents?: true
Size: 865 Bytes
Versions: 13
Compression:
Stored size: 865 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
13 entries across 13 versions & 1 rubygems