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

Returns a new instance of 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

:nodoc:



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

def dir
  @dir
end

#filenameObject

:nodoc:



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

def filename
  @filename
end

#methObject

:nodoc:



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

def meth
  @meth
end

#numObject

:nodoc:



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

def num
  @num
end

#pathObject

:nodoc:



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

Returns:

  • (Boolean)


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

def gem?
  @gem
end