File: test_string.rb

package info (click to toggle)
ruby-sshkit 1.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 604 kB
  • ctags: 619
  • sloc: ruby: 3,045; makefile: 2
file content (12 lines) | stat: -rw-r--r-- 230 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
class String

  def unindent
    indent = self.split("\n").select do |line|
      !line.strip.empty?
    end.map do |line|
      line.index(/[^\s]/)
    end.compact.min || 0
    self.gsub(/^[[:blank:]]{#{indent}}/, '')
  end

end