Class: Console::Output::Terminal::Buffer
- Inherits:
-
StringIO
- Object
- StringIO
- Console::Output::Terminal::Buffer
- Defined in:
- lib/console/output/terminal.rb
Overview
Represents an output buffer that formats lines with a prefix.
Instance Attribute Summary collapse
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
- #The prefix to use for each line.(prefixtouse) ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(prefix = nil) ⇒ Buffer
constructor
Create a new buffer with the given prefix.
-
#puts(*lines, prefix: @prefix) ⇒ Object
(also: #<<)
Write lines using the given prefix.
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
#prefix ⇒ Object (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 |