Sha256: e4d35062c6d65eba609a6852ea89cca93fe365ff954b6a98e2316d1763376b53
Contents?: true
Size: 780 Bytes
Versions: 14
Compression:
Stored size: 780 Bytes
Contents
# frozen_string_literal: true # IndentAction to indent code. class NodeMutation::IndentAction < NodeMutation::Action # Initialize a IndentAction. # # @param node [Node] # @param tab_size [Integer] tab size def initialize(node, tab_size = 1) super(node, nil) @tab_size = tab_size @type = :replace end # The rewritten source code with proper indent. # # @return [String] rewritten code. def new_code source = NodeMutation.adapter.get_source(@node) source.each_line.map { |line| (' ' * NodeMutation.tab_width * @tab_size) + line } .join end private # Calculate the begin the end positions. def calculate_position @start = NodeMutation.adapter.get_start(@node) @end = NodeMutation.adapter.get_end(@node) end end
Version data entries
14 entries across 14 versions & 1 rubygems