From: "rocky (Rocky Bernstein)" Date: 2013-08-19T10:34:35+09:00 Subject: [ruby-core:56739] [CommonRuby - Feature #8751] Add offsets to method#source_location Issue #8751 has been updated by rocky (Rocky Bernstein). =begin Although I think some other suggestion will be used if this issue gets addressed, I want to mention a cool implementation for representing source-code positions. I believe it would the right approach to take if things were done from scratch. The Go language has a compact way to represent a source code position (file, line and column) in a single (32-bit) word. See (()). If you look at how that is implemented, it can can trivially be extended to source-code ranges as well. =end ---------------------------------------- Feature #8751: Add offsets to method#source_location https://bugs.ruby-lang.org/issues/8751#change-41267 Author: tenderlovemaking (Aaron Patterson) Status: Open Priority: Normal Assignee: Category: Target version: Hello, I would like to have byte offsets returned on the source_location for methods. For example: def foo(&b) b.source_location # => [file_name, line_number, start_byte, end_byte] end If we had the start and end byte for a method or proc, then we could find the source for methods and procs in each file. There are some cases (like with heredocuments) where the "end of the method" could be after the `end` keyword. But I think if we just have offsets for the start of `def` and the end of `end`, I think it would cover 99% of usecases. -- http://bugs.ruby-lang.org/