Indent String

Add indentation to each line of a string.

Code

General
s.gsub(/^/, ' ' * spaces)

Parameters

Multi-line string

Number of spaces to indent

Server

More Ruby Snippets