Method: NodeMutation::PrependAction#new_code

Defined in:
lib/node_mutation/action/prepend_action.rb

#new_codeString

The rewritten source code with proper indent.

Returns:

  • (String)

    rewritten code.



18
19
20
21
22
23
24
# File 'lib/node_mutation/action/prepend_action.rb', line 18

def new_code
  if rewritten_source.split("\n").length > 1
    "\n" + rewritten_source.split("\n").map { |line| indent(@node) + line }.join("\n") + "\n"
  else
    indent(@node) + rewritten_source + "\n"
  end
end