Class: Line
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
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#meth ⇒ Object
Returns the value of attribute meth.
-
#num ⇒ Object
Returns the value of attribute num.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #codeline ⇒ Object
- #gem? ⇒ Boolean
-
#initialize(path, num, meth) ⇒ Line
constructor
A new instance of Line.
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
#dir ⇒ Object
Returns the value of attribute dir
8 9 10 |
# File 'lib/epitools/pretty_backtrace.rb', line 8 def dir @dir end |
#filename ⇒ Object
Returns the value of attribute filename
8 9 10 |
# File 'lib/epitools/pretty_backtrace.rb', line 8 def filename @filename end |
#meth ⇒ Object
Returns the value of attribute meth
8 9 10 |
# File 'lib/epitools/pretty_backtrace.rb', line 8 def meth @meth end |
#num ⇒ Object
Returns the value of attribute num
8 9 10 |
# File 'lib/epitools/pretty_backtrace.rb', line 8 def num @num end |
#path ⇒ Object
Returns the value of attribute path
8 9 10 |
# File 'lib/epitools/pretty_backtrace.rb', line 8 def path @path end |
Instance Method Details
#codeline ⇒ Object
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 |