Class: SyntaxTree::CLI::Color
- Inherits:
-
Object
- Object
- SyntaxTree::CLI::Color
- Defined in:
- lib/syntax_tree/cli.rb
Overview
A utility wrapper around colored strings in the output.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value, code) ⇒ Color
constructor
A new instance of Color.
- #to_s ⇒ Object
Constructor Details
#initialize(value, code) ⇒ Color
Returns a new instance of Color.
9 10 11 12 |
# File 'lib/syntax_tree/cli.rb', line 9 def initialize(value, code) @value = value @code = code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
7 8 9 |
# File 'lib/syntax_tree/cli.rb', line 7 def code @code end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/syntax_tree/cli.rb', line 7 def value @value end |
Class Method Details
.gray(value) ⇒ Object
18 19 20 |
# File 'lib/syntax_tree/cli.rb', line 18 def self.gray(value) new(value, "38;5;102") end |
.red(value) ⇒ Object
22 23 24 |
# File 'lib/syntax_tree/cli.rb', line 22 def self.red(value) new(value, "1;31") end |
.yellow(value) ⇒ Object
26 27 28 |
# File 'lib/syntax_tree/cli.rb', line 26 def self.yellow(value) new(value, "33") end |
Instance Method Details
#to_s ⇒ Object
14 15 16 |
# File 'lib/syntax_tree/cli.rb', line 14 def to_s "\033[#{code}m#{value}\033[0m" end |