Class: Line

Inherits:
Object show all
Defined in:
lib/epitools/pretty_backtrace.rb

Overview

TODO: Pick a backtrace format. (Also, add a method to replace default backtracer.) TODO: This chould be in a class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, num, meth) ⇒ Line


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/epitools/pretty_backtrace.rb', line 10

def initialize(path, num, meth)

  @path = path
  @num = num
  @meth = meth
  @gem = false

  @dir, @filename = File.split(path)

  if @dir =~ %r{^/usr/lib/ruby/gems/1.8/gems/(.+)}
    @dir = "[gem] #{$1}"
    @gem = true
  end

end

Instance Attribute Details

#dirObject

Returns the value of attribute dir


8
9
10
# File 'lib/epitools/pretty_backtrace.rb', line 8

def dir
  @dir
end

#filenameObject

Returns the value of attribute filename


8
9
10
# File 'lib/epitools/pretty_backtrace.rb', line 8

def filename
  @filename
end

#methObject

Returns the value of attribute meth


8
9
10
# File 'lib/epitools/pretty_backtrace.rb', line 8

def meth
  @meth
end

#numObject

Returns the value of attribute num


8
9
10
# File 'lib/epitools/pretty_backtrace.rb', line 8

def num
  @num
end

#pathObject

Returns the value of attribute path


8
9
10
# File 'lib/epitools/pretty_backtrace.rb', line 8

def path
  @path
end

Instance Method Details

#codelineObject


30
31
32
33
# File 'lib/epitools/pretty_backtrace.rb', line 30

def codeline
  l = @num.to_i - 1
  open(path).readlines[l]
end

#gem?Boolean


26
27
28
# File 'lib/epitools/pretty_backtrace.rb', line 26

def gem?
  @gem
end