Sha256: 693a181b049435d275f542c69489848537b96c62fffb4803ebc149087f134b86
Contents?: true
Size: 893 Bytes
Versions: 3
Compression:
Stored size: 893 Bytes
Contents
# frozen_string_literal: true module Synvert::Core # AppendAction to append code to the bottom of node body. class Rewriter::AppendAction < Rewriter::Action END_LENGTH = "\nend".length # Begin position to append code. # # @return [Integer] begin position. def begin_pos if :begin == @node.type @node.loc.expression.end_pos else @node.loc.expression.end_pos - @node.indent - END_LENGTH end end # End position, always same to begin position. # # @return [Integer] end position. def end_pos begin_pos end private # Indent of the node. # # @param node [Parser::AST::Node] # @return [String] n times whitesphace def indent(node) if %i[block class].include? node.type ' ' * (node.indent + DEFAULT_INDENT) else ' ' * node.indent end end end end
Version data entries
3 entries across 3 versions & 1 rubygems