Method: SyntaxSuggest::ExplainSyntax#why

Defined in:
lib/syntax_suggest/explain_syntax.rb

#why(miss) ⇒ Object

Converts a missing string to an human understandable explanation.

Example:

explain.why("}")
# => "Unmatched `{', missing `}' ?"


91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/syntax_suggest/explain_syntax.rb', line 91

def why(miss)
  case miss
  when "keyword"
    "Unmatched `end', missing keyword (`do', `def`, `if`, etc.) ?"
  when "end"
    "Unmatched keyword, missing `end' ?"
  else
    inverse = INVERSE.fetch(miss) {
      raise "Unknown explain syntax char or key: #{miss.inspect}"
    }
    "Unmatched `#{inverse}', missing `#{miss}' ?"
  end
end