Module: Acclaim::ANSI
- Defined in:
- lib/acclaim/ansi.rb
Overview
ANSI escape codes for colors and effects.
Class Method Summary collapse
-
.background_color(string, color) ⇒ String
Applies background color to the given string.
-
.effects(string, *effects) ⇒ String
Applies text effects to the given string.
-
.extend_string! ⇒ Object
Extends the String class with an object-oriented ANSI escape code API.
-
.foreground_color(string, color) ⇒ String
Applies foreground color to the given string.
-
.supported_colors ⇒ Array<Symbol>
(also: available_colors)
Colors from the standard color pallete.
-
.supported_effects ⇒ Array<Symbol>
(also: available_effects)
Text effects that can be applied.
Class Method Details
.background_color(string, color) ⇒ String
Applies background color to the given string.
64 65 66 |
# File 'lib/acclaim/ansi.rb', line 64 def background_color(string, color) apply_color_to string, color, background_offset end |
.effects(string, *effects) ⇒ String
Applies text effects to the given string.
74 75 76 77 78 79 80 81 82 |
# File 'lib/acclaim/ansi.rb', line 74 def effects(string, *effects) apply_escape_codes_to string do effects.select do |effect| text_effects.has_key? effect end.map do |effect| text_effects[effect] end end end |
.extend_string! ⇒ Object
Extends the String class with an object-oriented ANSI escape code API.
19 20 21 |
# File 'lib/acclaim/ansi.rb', line 19 def extend_string! require 'acclaim/core_extensions/string/ansi' end |
.foreground_color(string, color) ⇒ String
Applies foreground color to the given string.
53 54 55 |
# File 'lib/acclaim/ansi.rb', line 53 def foreground_color(string, color) apply_color_to string, color, foreground_offset end |
.supported_colors ⇒ Array<Symbol> Also known as: available_colors
Colors from the standard color pallete.
29 30 31 |
# File 'lib/acclaim/ansi.rb', line 29 def supported_colors colors.keys end |
.supported_effects ⇒ Array<Symbol> Also known as: available_effects
Text effects that can be applied.
40 41 42 |
# File 'lib/acclaim/ansi.rb', line 40 def supported_effects text_effects.keys end |