Class: CTioga2::Commands::ParsingContext

Inherits:
Object
  • Object
show all
Defined in:
lib/ctioga2/commands/context.rb

Overview

Context of parsing, mostly for error reporting

Instance Method Summary collapse

Instance Method Details

#parsing_file(command, file, line = -1)) ⇒ Object

Currently within a file



31
32
33
34
35
36
# File 'lib/ctioga2/commands/context.rb', line 31

def parsing_file(command, file, line = -1)
  @option = nil
  @command = command
  @file = file
  @number = line
end

#parsing_option(opt, number) ⇒ Object

Currently parsing an option



25
26
27
28
# File 'lib/ctioga2/commands/context.rb', line 25

def parsing_option(opt, number)
  @option = opt
  @number = number
end

#to_sObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ctioga2/commands/context.rb', line 38

def to_s
  if @option
    "option #{@option} (##{@number})"
  else
    file = @file.inspect
    if @file.respond_to?(:path)
      file = @file.path
    end
    if @command
      "command #{@command} in file '#{file}' line #{@number}"
    else
      "line #{@number} in file '#{file}'"
    end
  end
end