Module: Parser::Color
- Defined in:
- lib/parser/color.rb
Class Method Summary collapse
- .color(str, code, bold: false) ⇒ Object
- .green(str, bold: false) ⇒ Object
- .magenta(str, bold: false) ⇒ Object
- .red(str, bold: false) ⇒ Object
- .underline(str) ⇒ Object
- .yellow(str, bold: false) ⇒ Object
Class Method Details
.color(str, code, bold: false) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/parser/color.rb', line 5 def self.color(str, code, bold: false) return str unless STDOUT.tty? code = Array(code) code.unshift(1) if bold "\e[#{code.join(';')}m#{str}\e[0m" end |
.green(str, bold: false) ⇒ Object
16 17 18 |
# File 'lib/parser/color.rb', line 16 def self.green(str, bold: false) color(str, 32, bold: bold) end |
.magenta(str, bold: false) ⇒ Object
24 25 26 |
# File 'lib/parser/color.rb', line 24 def self.magenta(str, bold: false) color(str, 35, bold: bold) end |
.red(str, bold: false) ⇒ Object
12 13 14 |
# File 'lib/parser/color.rb', line 12 def self.red(str, bold: false) color(str, 31, bold: bold) end |
.underline(str) ⇒ Object
28 29 30 |
# File 'lib/parser/color.rb', line 28 def self.underline(str) color(str, 4) end |
.yellow(str, bold: false) ⇒ Object
20 21 22 |
# File 'lib/parser/color.rb', line 20 def self.yellow(str, bold: false) color(str, 33, bold: bold) end |