Class: Captivus::Backtrace::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/captivus/backtrace/line.rb

Constant Summary collapse

PATTERN =
/^(.+?):(\d+)(?::in `([^']+)')?$/

Instance Method Summary collapse

Constructor Details

#initialize(raw_line) ⇒ Line

Returns a new instance of Line.



6
7
8
9
10
11
12
13
14
# File 'lib/captivus/backtrace/line.rb', line 6

def initialize(raw_line)
  if match_data = PATTERN.match(raw_line)
    @file = match_data[1]
    @number = match_data[2].to_i
    @method = match_data[3]
  else
    raise ArgumentError, "Unrecognized format: #{raw_line.inspect}"
  end
end

Instance Method Details

#as_jsonObject



16
17
18
19
20
# File 'lib/captivus/backtrace/line.rb', line 16

def as_json(*)
  hash = {'file' => file, 'number' => number}
  hash['method'] = method if method
  hash
end