Sha256: eefc3c64eb79d0cfc905873f56fe68fbf7dba35aafc5f239b775821556716778
Contents?: true
Size: 366 Bytes
Versions: 10
Compression:
Stored size: 366 Bytes
Contents
# Removes common indentation from an array of strings class Array def remove_indent lines_with_indent = self.select do |line| line.size > 0 end indents = lines_with_indent.map do |line| match = line.match(/^( +)([^ ]|$)+/) match ? match[1].size : 0 end indent = indents.min self.map do |line| line[indent..-1] end end end # vim: nospell
Version data entries
10 entries across 8 versions & 1 rubygems