class String

github.com/Mynyml/Unindent/

Public Instance Methods

unindent() click to toggle source
# File lib/core/string.rb, line 14
def unindent
  indent = self.split("\n").select {|line| !line.strip.empty? }.map {|line| line.index(/[^\s]/) }.compact.min || 0
  self.gsub(/^[[:blank:]]{#{indent}}/, '')
end
unindent!() click to toggle source
# File lib/core/string.rb, line 18
def unindent!
  self.replace(self.unindent)
end