Class: PrettyPrint::Buffer::StringBuffer
- Inherits:
-
DefaultBuffer
- Object
- DefaultBuffer
- PrettyPrint::Buffer::StringBuffer
- Defined in:
- lib/syntax_tree/prettyprint.rb
Overview
This is an output buffer that wraps a string output object. It provides a trim! method that trims off trailing whitespace from the string using gsub!.
Instance Attribute Summary
Attributes inherited from DefaultBuffer
Instance Method Summary collapse
-
#initialize(output = "".dup) ⇒ StringBuffer
constructor
A new instance of StringBuffer.
- #trim! ⇒ Object
Methods inherited from DefaultBuffer
Constructor Details
#initialize(output = "".dup) ⇒ StringBuffer
Returns a new instance of StringBuffer.
294 295 296 |
# File 'lib/syntax_tree/prettyprint.rb', line 294 def initialize(output = "".dup) super(output) end |
Instance Method Details
#trim! ⇒ Object
298 299 300 301 302 |
# File 'lib/syntax_tree/prettyprint.rb', line 298 def trim! length = output.length output.gsub!(/[\t ]*\z/, "") length - output.length end |