Class: Crashdesk::Backtrace

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

Defined Under Namespace

Classes: Line

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lines) ⇒ Backtrace

Returns a new instance of Backtrace.



57
58
59
# File 'lib/crashdesk/backtrace.rb', line 57

def initialize(lines)
  self.lines = lines
end

Instance Attribute Details

#linesObject

Returns the value of attribute lines.



41
42
43
# File 'lib/crashdesk/backtrace.rb', line 41

def lines
  @lines
end

Class Method Details

.parse(backtrace, opts = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/crashdesk/backtrace.rb', line 43

def self.parse(backtrace, opts = {})
  code_lines = split_multiline_backtrace(backtrace)

  lines = unless code_lines.nil?
    code_lines.collect do |unparsed_line|
      Line.parse(unparsed_line)
    end
  else
    []
  end

  instance = new(lines)
end

Instance Method Details

#==(other) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/crashdesk/backtrace.rb', line 73

def ==(other)
  if other.respond_to?(:lines)
    lines == other.lines
  else
    false
  end
end

#crcObject



85
86
87
# File 'lib/crashdesk/backtrace.rb', line 85

def crc
  Zlib::crc32(to_s).to_s
end

#hash_idObject



81
82
83
# File 'lib/crashdesk/backtrace.rb', line 81

def hash_id
  Digest::MD5.hexdigest(to_s)
end

#inspectObject



61
62
63
# File 'lib/crashdesk/backtrace.rb', line 61

def inspect
  "<Backtrace: " + lines.collect { |line| line.inspect }.join(", ") + ">"
end

#to_aObject



69
70
71
# File 'lib/crashdesk/backtrace.rb', line 69

def to_a
  lines.map { |l| l.to_s }
end

#to_sObject



65
66
67
# File 'lib/crashdesk/backtrace.rb', line 65

def to_s
  lines.join("\n\s")
end