Skip to content

Instantly share code, notes, and snippets.

@ashrithr
Last active May 18, 2017 04:53
Show Gist options
  • Save ashrithr/5905421 to your computer and use it in GitHub Desktop.
Save ashrithr/5905421 to your computer and use it in GitHub Desktop.

Revisions

  1. ashrithr revised this gist Jul 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion undent.rb
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,4 @@ def undent
    ..another line
    EOS

    puts test.inspect
    puts test.inspect # => "testing unindent\nanother line\n"
  2. ashrithr created this gist Jul 1, 2013.
    13 changes: 13 additions & 0 deletions undent.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    class String
    def undent
    gsub(/^.{#{slice(/^ +/).length}}/, '')
    end
    end

    #Usage:
    test = <<-EOS.undent
    testing unindent
    ..another line
    EOS

    puts test.inspect