Module: Runbook::Helpers::FormatHelper
- Included in:
- Run::ClassMethods, Views::Markdown
- Defined in:
- lib/runbook/helpers/format_helper.rb
Instance Method Summary collapse
Instance Method Details
#deindent(str, padding: 0) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/runbook/helpers/format_helper.rb', line 3 def deindent(str, padding: 0) lines = str.split("\n") indentations = lines.map { |l| l.size - l.gsub(/^\s+/, "").size } min_indentation = indentations.min lines.map! { |line| " " * padding + line[min_indentation..-1] } lines.join("\n") end |