Class: BruteCLI::Terminal
- Inherits:
-
Object
- Object
- BruteCLI::Terminal
- Defined in:
- lib/brute_cli/terminal.rb
Overview
Single owner of all terminal output. Every object that needs to write to the terminal receives a Terminal instance and writes through its buffer — nothing calls puts/print/$stdout directly.
terminal = Terminal.new
terminal.buffer << "hello" # prints with newline
terminal.buffer.print "\e7" # raw print, no newline
terminal.buffer.warn "uh oh" # prints to stderr
Defined Under Namespace
Classes: Buffer
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
Instance Method Summary collapse
-
#initialize ⇒ Terminal
constructor
A new instance of Terminal.
- #separator(thick: false) ⇒ Object
- #width ⇒ Object
Constructor Details
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
17 18 19 |
# File 'lib/brute_cli/terminal.rb', line 17 def buffer @buffer end |
Instance Method Details
#separator(thick: false) ⇒ Object
27 28 29 |
# File 'lib/brute_cli/terminal.rb', line 27 def separator(thick: false) BufferOutput::Separator.new(width: width, thick: thick) end |
#width ⇒ Object
23 24 25 |
# File 'lib/brute_cli/terminal.rb', line 23 def width TTY::Screen.width end |