Class: Console::Output::Terminal::Buffer

Inherits:
StringIO
  • Object
show all
Defined in:
lib/console/output/terminal.rb

Overview

Represents an output buffer that formats lines with a prefix.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix = nil) ⇒ Buffer

Create a new buffer with the given prefix.



24
25
26
27
28
# File 'lib/console/output/terminal.rb', line 24

def initialize(prefix = nil)
	@prefix = prefix
	
	super()
end

Instance Attribute Details

#prefixObject (readonly)

Returns the value of attribute prefix.



31
32
33
# File 'lib/console/output/terminal.rb', line 31

def prefix
  @prefix
end

#The prefix to use for each line.(prefixtouse) ⇒ Object (readonly)



31
# File 'lib/console/output/terminal.rb', line 31

attr :prefix

Instance Method Details

#puts(*lines, prefix: @prefix) ⇒ Object Also known as: <<

Write lines using the given prefix.



37
38
39
40
41
42
# File 'lib/console/output/terminal.rb', line 37

def puts(*lines, prefix: @prefix)
	lines.each do |line|
		self.write(prefix) if prefix
		super(line)
	end
end