Sha256: 578027d983b9694752dfb9395e64af90fc4e59af1492656e51e42cb3f1ac0ca9

Contents?: true

Size: 259 Bytes

Versions: 17

Compression:

Stored size: 259 Bytes

Contents

class String
  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
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
cronicle-0.1.1 lib/cronicle/ext/string_ext.rb
cronicle-0.1.0 lib/cronicle/ext/string_ext.rb
ridgepole-0.2.3 lib/ridgepole/string_ext.rb
ridgepole-0.2.2 lib/ridgepole/string_ext.rb
ridgepole-0.2.1 lib/ridgepole/string_ext.rb
ridgepole-0.2.0 lib/ridgepole/string_ext.rb
ridgepole-0.1.9 lib/ridgepole/string_ext.rb
ridgepole-0.1.8 lib/ridgepole/string_ext.rb
ridgepole-0.1.7 lib/ridgepole/string_ext.rb
ridgepole-0.1.6 lib/ridgepole/string_ext.rb
ridgepole-0.1.5 lib/ridgepole/string_ext.rb
ridgepole-0.1.4 lib/ridgepole/string_ext.rb
ridgepole-0.1.3 lib/ridgepole/string_ext.rb
ridgepole-0.1.2 lib/ridgepole/string_ext.rb
ridgepole-0.1.1 lib/ridgepole/string_ext.rb
ridgepole-0.1.0 lib/ridgepole/string_ext.rb
ridgepole-0.0.1 lib/ridgepole/string_ext.rb