File: strip_helper.rb

package info (click to toggle)
ruby-morpher 0.2.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 520 kB
  • sloc: ruby: 2,366; makefile: 4
file content (12 lines) | stat: -rw-r--r-- 262 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
module StripHelper
  def strip(text)
    return text if text.empty?
    lines = text.lines
    match = /\A[ ]*/.match(lines.first)
    range = match[0].length..-1
    source = lines.map do |line|
      line[range]
    end.join
    source.chomp << "\n"
  end
end