Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_grammar_builder/util.rb

Overview

Add remove indent to the String class

Instance Method Summary collapse

Instance Method Details

#remove_indentString

a helper for writing multi-line strings for error messages example usage

puts <<-HEREDOC.remove_indent
This command does such and such.
    this part is extra indented
HEREDOC

Returns:



26
27
28
# File 'lib/ruby_grammar_builder/util.rb', line 26

def remove_indent
    gsub(/^[ \t]{#{match(/^[ \t]*/)[0].length}}/, '')
end