Sha256: fb936f251cfb064a8df4f223fb4118d0bfff3e8fb9ba7049f8cd91f34f91b523

Contents?: true

Size: 290 Bytes

Versions: 13

Compression:

Stored size: 290 Bytes

Contents

class ::String
  # Trim beginning of each line by the amount of indentation in the first line
  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
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rdf-rdfa-3.3.0 lib/rdf/rdfa/patches/string_hacks.rb
rdf-rdfa-3.2.3 lib/rdf/rdfa/patches/string_hacks.rb
rdf-rdfa-3.2.2 lib/rdf/rdfa/patches/string_hacks.rb
rdf-rdfa-3.2.1 lib/rdf/rdfa/patches/string_hacks.rb
rdf-rdfa-3.2.0 lib/rdf/rdfa/patches/string_hacks.rb
rdf-rdfa-3.1.3 lib/rdf/rdfa/patches/string_hacks.rb
rdf-rdfa-3.1.2 lib/rdf/rdfa/patches/string_hacks.rb
rdf-rdfa-3.1.1 lib/rdf/rdfa/patches/string_hacks.rb
rdf-rdfa-3.1.0 lib/rdf/rdfa/patches/string_hacks.rb
rdf-rdfa-3.0.1 lib/rdf/rdfa/patches/string_hacks.rb
rdf-rdfa-3.0.0 lib/rdf/rdfa/patches/string_hacks.rb
rdf-rdfa-2.2.4 lib/rdf/rdfa/patches/string_hacks.rb
rdf-rdfa-2.2.3 lib/rdf/rdfa/patches/string_hacks.rb