Module: Gemmy::Patches::StringPatch::InstanceMethods::Indent

Defined in:
lib/gemmy/patches/string_patch.rb

Instance Method Summary collapse

Instance Method Details

#indent(n, c = ' ') ⇒ Object

facets



186
187
188
189
190
191
192
# File 'lib/gemmy/patches/string_patch.rb', line 186

def indent(n, c=' ')
  if n >= 0
    gsub(/^/, c * n)
  else
    gsub(/^#{Regexp.escape(c)}{0,#{-n}}/, "")
  end
end