Permalink
Browse files

Proc#line and #file can be used without calling #source_descriptor fi…

…rst. #line now returns an integer
  • Loading branch information...
1 parent 903e5dc commit c5310c05e9e111298fa23d7b9b361f762f26a5a8 @notro notro committed Mar 3, 2011
Showing with 12 additions and 2 deletions.
  1. +12 −2 lib/proc_source.rb
View
14 lib/proc_source.rb
@@ -182,7 +182,6 @@ def self.get_lines(filename, start_line = 0)
end
class Proc #:nodoc:
- attr_reader :file, :line
attr_writer :source
def source_descriptor
@@ -193,13 +192,24 @@ def source_descriptor
@file, @line = md.captures
end
end
- [@file, @line.to_i]
+ @line = @line.to_i
+ [@file, @line]
end
def source
@source ||= ProcSource.find(*self.source_descriptor)
end
+ def line
+ source_descriptor
+ @line
+ end
+
+ def file
+ source_descriptor
+ @file
+ end
+
# Dump to Marshal format.
# p = Proc.new { false }
# Marshal.dump p

0 comments on commit c5310c0

Please sign in to comment.