Exception: Calyx::Errors::UndefinedRule
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Calyx::Errors::UndefinedRule
- Defined in:
- lib/calyx/errors.rb
Overview
Instance Method Summary collapse
-
#initialize(rule, symbol) ⇒ UndefinedRule
constructor
A new instance of UndefinedRule.
- #source_line ⇒ Object
- #trace_api_boundary(trace) ⇒ Object
Constructor Details
#initialize(rule, symbol) ⇒ UndefinedRule
Returns a new instance of UndefinedRule.
14 15 16 17 18 19 20 21 22 |
# File 'lib/calyx/errors.rb', line 14 def initialize(rule, symbol) @trace = if rule rule.trace else trace_api_boundary(caller_locations) end super("undefined rule :#{symbol} in #{@trace.path}:#{@trace.lineno}:`#{source_line}`") end |
Instance Method Details
#source_line ⇒ Object
32 33 34 35 36 37 |
# File 'lib/calyx/errors.rb', line 32 def source_line File.open(@trace.absolute_path) do |source| (@trace.lineno-1).times { source.gets } source.gets end.strip end |
#trace_api_boundary(trace) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/calyx/errors.rb', line 24 def trace_api_boundary(trace) (trace.count - 1).downto(0) do |index| if trace[index].to_s.include?('lib/calyx/') return trace[index + 1] end end end |