Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/loquacious/core_ext/string.rb
Instance Method Summary collapse
-
#gutter ⇒ Object
call-seq: “ | foon | bar”.gutter! #=> “ foon bar”.
-
#gutter! ⇒ Object
call-seq: “ | foon | bar”.gutter! #=> “ foon bar”.
Instance Method Details
#gutter ⇒ Object
call-seq:
" | foo\n | bar".gutter! #=> " foo\n bar"
Removes a leading gutter from all lines in the string. The gutter is defined leading whitespace followed by a single pipe character. This method is very useful with heredocs.
24 25 26 |
# File 'lib/loquacious/core_ext/string.rb', line 24 def gutter self.dup.gutter! end |
#gutter! ⇒ Object
call-seq:
" | foo\n | bar".gutter! #=> " foo\n bar"
Removes a leading gutter from all lines in the string. The gutter is defined leading whitespace followed by a single pipe character. This method is very useful with heredocs.
The string will be altered by this method.
12 13 14 15 |
# File 'lib/loquacious/core_ext/string.rb', line 12 def gutter! gsub! %r/^[\t\f\r ]*\|?/, '' self end |