class Guileless::OutputBuffer

Public Class Methods

new() click to toggle source
# File lib/guileless/output_buffer.rb, line 3
def initialize
  @output_buffer = []
  @output = []
end

Public Instance Methods

add(str) click to toggle source
# File lib/guileless/output_buffer.rb, line 8
def add(str)
  str = str.chars.to_a if str.kind_of?(String)
  @output_buffer += Array(str)
  str
end
buffered?() click to toggle source
# File lib/guileless/output_buffer.rb, line 14
def buffered?
  @output_buffer.length > 0
end
flush() click to toggle source
# File lib/guileless/output_buffer.rb, line 18
def flush
  @output += @output_buffer
  @output_buffer = []
end
to_s() click to toggle source
# File lib/guileless/output_buffer.rb, line 29
def to_s
  @output.join
end
wrap(prefix, postfix) click to toggle source
# File lib/guileless/output_buffer.rb, line 23
def wrap(prefix, postfix)
  prefix = prefix.chars.to_a if prefix.kind_of?(String)
  postfix = postfix.chars.to_a if postfix.kind_of?(String)
  @output_buffer = Array(prefix) + @output_buffer + Array(postfix)
end