Sha256: c3371c0079999b062cd72d1aa1f8297b127174bee7f331f7220f74337732a1f1
Contents?: true
Size: 851 Bytes
Versions: 32
Compression:
Stored size: 851 Bytes
Contents
# frozen_string_literal: true module Synvert::Core # ReplaceAction to replace child node with code. class Rewriter::ReplaceAction < Rewriter::Action def initialize(instance, *selectors, with:) @instance = instance @selectors = selectors @code = with @node = @instance.current_node end # Begin position of code to replace. # # @return [Integer] begin position. def begin_pos @selectors.map { |selector| @node.child_node_range(selector).begin_pos }.min end # End position of code to replace. # # @return [Integer] end position. def end_pos @selectors.map { |selector| @node.child_node_range(selector).end_pos }.max end # The rewritten source code. # # @return [String] rewritten code. def rewritten_code rewritten_source end end end
Version data entries
32 entries across 32 versions & 1 rubygems