Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/ridgepole/string_ext.rb
Instance Method Summary collapse
Instance Method Details
#undent ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/ridgepole/string_ext.rb', line 2 def undent min_space_num = self.split("\n").delete_if {|s| s =~ /^\s*$/ }.map {|s| (s[/^\s+/] || '').length }.min if min_space_num and min_space_num > 0 gsub(/^[ \t]{,#{min_space_num}}/, '') else self end end |