Sha256: f2a9ac37887c337af20d5758d17f26d3ed1d163ca956b3e4d5653bee7e60e3a9
Contents?: true
Size: 611 Bytes
Versions: 25
Compression:
Stored size: 611 Bytes
Contents
module JSONAPIonify module IndentedString extend self refine String do def deindent shortest_line_length = lines.each_with_object([]) do |line, ary| next if line.empty? ary << line.match(/^\s*/)[0].length if line.rstrip.present? end.sort.first lines.map do |string| if string.length && !string.match(/^\s*$/) string.rstrip[shortest_line_length..-1] else string end end.join("\n") end end using self def deindent_string(string) string.deindent end end end
Version data entries
25 entries across 25 versions & 1 rubygems