Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/rdf/rdfa/patches/string_hacks.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) align_left

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



3
4
5
6
7
8
# 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