Class: SyntaxErrorSearch::WhoDisSyntaxError
- Defined in:
- lib/syntax_search/who_dis_syntax_error.rb
Overview
Determines what type of syntax error is in the source
Example:
puts WhoDisSyntaxError.new("def foo;").call.error_symbol
# => :missing_end
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#error_symbol ⇒ Object
readonly
Returns the value of attribute error_symbol.
-
#run_once ⇒ Object
readonly
Returns the value of attribute run_once.
Instance Method Summary collapse
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
11 12 13 |
# File 'lib/syntax_search/who_dis_syntax_error.rb', line 11 def error @error end |
#error_symbol ⇒ Object (readonly)
Returns the value of attribute error_symbol.
11 12 13 |
# File 'lib/syntax_search/who_dis_syntax_error.rb', line 11 def error_symbol @error_symbol end |
#run_once ⇒ Object (readonly)
Returns the value of attribute run_once.
11 12 13 |
# File 'lib/syntax_search/who_dis_syntax_error.rb', line 11 def run_once @run_once end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/syntax_search/who_dis_syntax_error.rb', line 13 def call @run_once ||= begin parse true end self end |
#on_parse_error(msg) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/syntax_search/who_dis_syntax_error.rb', line 21 def on_parse_error(msg) @error = msg if @error.match?(/unexpected end-of-input/) @error_symbol = :missing_end elsif @error.match?(/unexpected `end'/) || @error.match?(/expecting end-of-input/) @error_symbol = :unmatched_end else @error_symbol = :nope end end |