Module: PrettyPrint::Buffer

Defined in:
lib/syntax_tree/prettyprint.rb

Overview

When building up the contents in the output buffer, it’s convenient to be able to trim trailing whitespace before newlines. If the output object is a string or array or strings, then we can do this with some gsub calls. If not, then this effectively just wraps the output object and forwards on calls to <<.

Defined Under Namespace

Classes: ArrayBuffer, DefaultBuffer, StringBuffer

Class Method Summary collapse

Class Method Details

.for(output) ⇒ Object

This is a switch for building the correct output buffer wrapper class for the given output object.



336
337
338
339
340
341
342
343
344
345
# File 'lib/syntax_tree/prettyprint.rb', line 336

def self.for(output)
  case output
  when String
    StringBuffer.new(output)
  when Array
    ArrayBuffer.new(output)
  else
    DefaultBuffer.new(output)
  end
end