Module: ErrorHighlight::CoreExt

Defined in:
lib/error_highlight/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#detailed_message(highlight: false, error_highlight: true) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/error_highlight/core_ext.rb', line 12

def detailed_message(highlight: false, error_highlight: true, **)
  return super unless error_highlight
  snippet = generate_snippet
  if highlight
    snippet = snippet.gsub(/.+/) { "\e[1m" + $& + "\e[m" }
  end
  super + snippet
end

#to_sObject



27
28
29
30
31
32
33
34
35
# File 'lib/error_highlight/core_ext.rb', line 27

def to_s
  msg = super
  snippet = generate_snippet
  if snippet != "" && !msg.include?(snippet)
    msg + snippet
  else
    msg
  end
end