Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/gluez/ext/string.rb

Instance Method Summary collapse

Instance Method Details

#strip2Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/gluez/ext/string.rb', line 2

def strip2
  unless self.empty?
    lines = self.split("\n")
    indent = 0
    lines[0].each_char do |char|
      if char == " "
        indent += 1
      else
        break
      end
    end
    lines.collect{|line| line.gsub(/^([ ]{0,#{indent}})/, "")}.join("\n")
  else
    self
  end
end