Module: Plywood::Color
- Defined in:
- lib/plywood/color.rb
Constant Summary collapse
- ANSI =
{ reset: 0, black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, white: 37, bright_black: 30, bright_red: 31, bright_green: 32, bright_yellow: 33, bright_blue: 34, bright_magenta: 35, bright_cyan: 36, bright_white: 37 }.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.enable(io) ⇒ Object
22 23 24 |
# File 'lib/plywood/color.rb', line 22 def self.enable(io) io.extend(self) end |
Instance Method Details
#color(name) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/plywood/color.rb', line 31 def color(name) return "" unless color? ansi = ANSI[name.to_sym] return "" if ansi.nil? "\e[#{ansi}m" end |
#color? ⇒ Boolean
26 27 28 29 |
# File 'lib/plywood/color.rb', line 26 def color? return false unless respond_to?(:isatty) isatty && ENV["TERM"] end |