class String

Public Instance Methods

align_left() click to toggle source

Trim beginning of each line by the amount of indentation in the first line

# File lib/rdf/rdfa/patches/string_hacks.rb, line 3
def align_left
  str = self.sub(/^\s*$/, '')  # Remove leading newline
  str = str[1..-1] if str[0,1] == "\n"
  ws = str.match(/^(\s*)\S/m) ? $1 : ''
  str.gsub(/^#{ws}/m, '')
end