class Buffer
Represents an output buffer that formats lines with a prefix.
Definitions
def initialize(prefix = nil)
Create a new buffer with the given prefix.
Signature
-
parameter
prefix
String
The prefix to use for each line.
Implementation
def initialize(prefix = nil)
@prefix = prefix
super()
end
attr :prefix
Signature
-
attribute
String
The prefix to use for each line.
def puts(*lines, prefix: @prefix)
Write lines using the given prefix.
Signature
-
parameter
lines
Array
The lines to write.
-
parameter
prefix
String
The prefix to use for each line.
Implementation
def puts(*lines, prefix: @prefix)
lines.each do |line|
self.write(prefix) if prefix
super(line)
end
end