class String

Public Instance Methods

indent(n, c=' ') click to toggle source
# File lib/courtier/core_ext.rb, line 44
def indent(n, c=' ')
  if n >= 0
    gsub(/^/, c * n)
  else
    gsub(/^#{Regexp.escape(c)}{0,#{-n}}/, "")
  end
end
tabto(n) click to toggle source
# File lib/courtier/core_ext.rb, line 36
def tabto(n)
  if self =~ /^( *)\S/
    indent(n - $1.length)
  else
    self
  end
end