Module: Repctl::Color

Defined in:
lib/repctl/color.rb

Defined Under Namespace

Modules: Constants

Instance Method Summary collapse

Instance Method Details

#colorize(color, bold = false) ⇒ Object

Set color by using a string or one of the defined constants. If a third option is set to true, it also adds bold to the string. This is based on Highline implementation and it automatically appends CLEAR to the end of the returned String.



50
51
52
53
54
# File 'lib/repctl/color.rb', line 50

def colorize(color, bold = false)
 color = Constants.const_get(color.to_s.upcase) if color.is_a?(Symbol)
 bold  = bold ? Constants::BOLD : ""
 "#{bold}#{color}#{self.to_s}#{Constants::CLEAR}"
end