Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core/string.rb
Overview
Instance Method Summary collapse
Instance Method Details
#unindent ⇒ Object
14 15 16 17 |
# File 'lib/core/string.rb', line 14 def unindent indent = self.split("\n").select {|line| !line.strip.empty? }.map {|line| line.index(/[^\s]/) }.compact.min || 0 self.gsub(/^[[:blank:]]{#{indent}}/, '') end |
#unindent! ⇒ Object
18 19 20 |
# File 'lib/core/string.rb', line 18 def unindent! self.replace(self.unindent) end |