Module: DeepCover::Tools::IndentString

Defined in:
lib/deep_cover/tools/indent_string.rb

Constant Summary collapse

IMPLEMENTATION =

In-place implementation copied from active-support.

->(amount, indent_string = nil, indent_empty_lines = false) do
  indent_string = indent_string || self[/^[ \t]/] || ' '
  re = indent_empty_lines ? /^/ : /^(?!$)/
  gsub!(re, indent_string * amount)
end

Instance Method Summary collapse

Instance Method Details

#indent_string(string, *args) ⇒ Object



20
21
22
23
24
# File 'lib/deep_cover/tools/indent_string.rb', line 20

def indent_string(string, *args)
  string = string.dup
  indent_string!(string, *args)
  string
end

#indent_string!(string, *args) ⇒ Object



14
15
16
# File 'lib/deep_cover/tools/indent_string.rb', line 14

def indent_string!(string, *args)
  string.instance_exec(*args, &IMPLEMENTATION)
end