2012-08-16 12:02:03 -04:00
|
|
|
module CompressHelper
|
|
|
|
def strip_indent(string)
|
2013-07-28 15:16:45 -04:00
|
|
|
lines = string.lines
|
|
|
|
match = /\A( *)/.match(lines.first)
|
2014-08-11 10:29:32 -04:00
|
|
|
return string unless match
|
2012-08-16 12:02:03 -04:00
|
|
|
whitespaces = match[1].to_s.length
|
2013-07-28 15:16:45 -04:00
|
|
|
lines.map { |line| line[whitespaces..-1] }.join
|
2012-08-16 12:02:03 -04:00
|
|
|
end
|
2016-04-10 17:33:47 -04:00
|
|
|
end # CompressHelper
|