Method: Command::Results::Formatter::Styler#style

Defined in:
lib/command-set/formatter/base.rb

#style(text, options) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/command-set/formatter/base.rb', line 34

def style(text, options)
  options ||= {}
  if options.key? :format_advice
    options = options.merge(options[:format_advice]) 
  end
  aliased = {
    :foreground => options[:color],
    :extra => options[:text_style]
  }
  options = aliased.merge(options)
  markup = code_for(Foregrounds, options[:foreground]) + 
    code_for(Backgrounds, options[:background]) + 
    code_for(Extras, options[:extra])
  return text if markup.empty?
  return markup + text + code_for(Extras, "clear")
end