Sha256: 68ecc3c49eb3092f3704d5ae00169947bd93c41600f2cd5efa79fe2a3543007b
Contents?: true
Size: 331 Bytes
Versions: 3
Compression:
Stored size: 331 Bytes
Contents
class String def unindent(options = {}) tablength = options[:tablength] || 2 lines = gsub("\t", " " * tablength).split("\n") whitespace = lines.map do |line| line.match(/^(\s+)/).captures.first end.min{ |l, r| l.length <=> r.length } lines.map{ |l| l.gsub /^#{whitespace}/, ''}.join("\n") end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
freighthopper-0.1.12 | lib/freighthopper/string/unindent.rb |
freighthopper-0.1.11 | lib/freighthopper/string/unindent.rb |
freighthopper-0.1.9 | lib/freighthopper/string/unindent.rb |