Class: Brut::TUI::AnsiEscapeCode
- Inherits:
-
Object
- Object
- Brut::TUI::AnsiEscapeCode
- Extended by:
- Mod
- Defined in:
- lib/brut/tui/ansi_escape_code.rb
Overview
Maps ANSI escape codes to logical names to make it easier to use in code. This is not intended to be exhaustive, but could grow over time as needed.
Defined Under Namespace
Modules: Mod
Constant Summary
Constants included from Mod
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, code) ⇒ AnsiEscapeCode
constructor
Create a new AnsiEscapeCode with the given name and code.
-
#to_s ⇒ Object
Returns the code suitable for sending to the terminal.
Methods included from Mod
Constructor Details
#initialize(name, code) ⇒ AnsiEscapeCode
Create a new AnsiEscapeCode with the given name and code.
12 13 14 15 |
# File 'lib/brut/tui/ansi_escape_code.rb', line 12 def initialize(name, code) @name = name.to_sym @code = code end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/brut/tui/ansi_escape_code.rb', line 5 def name @name end |
Instance Method Details
#to_s ⇒ Object
Returns the code suitable for sending to the terminal.
18 |
# File 'lib/brut/tui/ansi_escape_code.rb', line 18 def to_s = "\e[#{@code}m" |