Exception: Rundoc::CodeSection::ParseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rundoc/code_section.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ParseError

Returns a new instance of ParseError.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rundoc/code_section.rb', line 9

def initialize(options = {})
  keyword = options[:keyword]
  command = options[:command]
  line_number = options[:line_number]
  block = options[:block].lines.map do |line|
    if line == command
      "    > #{line}"
    else
      "      #{line}"
    end
  end.join("")

  msg = "Error parsing (line:#{line_number}):\n"
  msg << ">  '#{command.strip}'\n"
  msg << "No such registered command: '#{keyword}'\n"
  msg << "registered commands: #{Rundoc.known_commands.inspect}\n\n"
  msg << block
  msg << "\n"
  super(msg)
end