Sha256: 7be38a12e298ef9f563e4c206ea15d2d10c8d1da771cc044587fbd246cf5bca9
Contents?: true
Size: 742 Bytes
Versions: 13
Compression:
Stored size: 742 Bytes
Contents
# frozen_string_literal: true module Synvert::Core # AppendAction appends code to the bottom of node body. class Rewriter::AppendAction < Rewriter::Action private END_LENGTH = "\nend".length # Calculate the begin the end positions. def calculate_position @begin_pos = :begin == @node.type ? @node.loc.expression.end_pos : @node.loc.expression.end_pos - @node.column - END_LENGTH @end_pos = @begin_pos end # Indent of the node. # # @param node [Parser::AST::Node] # @return [String] n times whitesphace def indent(node) if %i[block class def defs].include? node.type ' ' * (node.column + DEFAULT_INDENT) else ' ' * node.column end end end end
Version data entries
13 entries across 13 versions & 1 rubygems