Module: Assert::View::Helpers::AnsiStyles

Defined in:
lib/assert/view/helpers/ansi.rb

Instance Method Summary collapse

Instance Method Details

#ansi_style(*ansi_codes) ⇒ Object



19
20
21
# File 'lib/assert/view/helpers/ansi.rb', line 19

def ansi_style(*ansi_codes)
  ansi_codes.collect{|code| ANSI.send(code) rescue nil}.compact.join('')
end

#ansi_styled_msg(msg, styles = []) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/assert/view/helpers/ansi.rb', line 11

def ansi_styled_msg(msg, styles=[])
  if !(style = ansi_style(*styles)).empty?
    style + msg + ANSI.send(:reset)
  else
    msg
  end
end

#result_ansi_styles(result) ⇒ Object



7
8
9
# File 'lib/assert/view/helpers/ansi.rb', line 7

def result_ansi_styles(result)
  view.options.styled ? view.options.send("#{result.to_sym}_styles") : []
end